return fact

This commit is contained in:
Jacob Janzen 2024-12-30 21:08:53 -06:00
parent 52e956746a
commit 128f3d63ea

View file

@ -51,8 +51,12 @@ export function catfact(state) {
get("https://meowfacts.herokuapp.com/", (res) => { get("https://meowfacts.herokuapp.com/", (res) => {
res.on("data", (d) => { res.on("data", (d) => {
process.stdout.write(d); process.stdout.write(d);
const obj = JSON.parse(d);
const fact = obj.data[0];
return send(state, { content: fact });
}); });
}).on("error", (e) => { }).on("error", (e) => {
console.error(e); console.error(e);
return send(state, { content: "failed to request fact" });
}); });
} }