errorhandling oder so

This commit is contained in:
Flummi 2018-09-02 16:51:32 +02:00
parent 305417b6d0
commit b1b1781bce

View File

@ -26,15 +26,15 @@ export default bot => {
const tmp = url.parse(link).path.substr(1);
rp(apis.reverse + tmp)
.then(res => {
console.log(res);
return JSON.parse(res).id;
if(res.error)
throw res.error;
return JSON.parse(res).data.id;
})
.then(id => Promise.all([
rp(apis.pr0gag.list + id.toString()),
rp(apis.pr0gag.item + id.toString()),
id
])
.then(([list, item, id]) => [
]).then(([list, item, id]) => [
JSON.parse(list).items.filter(item => item.id === id)[0],
JSON.parse(item),
id
@ -64,7 +64,10 @@ export default bot => {
`l: ${meta.link}`
].join("; "))
.then(out => e.reply(out))
);
)
.catch(err => {
e.reply( JSON.stringify(err));
});
}
}));
};