I'm having trouble doing an operation in which I tweet image
The error:
Error: ENOENT: no such file or directory, open 'https://cdn.nekos.life/neko/neko088.jpg'
at Object.openSync (fs.js:454:3)
at Object.readFileSync (fs.js:354:35)
at twtRandomNeko (/app/bot.js:77:25)
at processTicksAndRejections (internal/process/task_queues.js:88:5) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: 'https://cdn.nekos.life/neko/neko088.jpg'
}
Here's the code:
async function twtRandomNeko() {
const body = await superagent.get("https://nekos.life/api/neko");
const img = body.neko;
console.log(img); //example: https://cdn.nekos.life/neko/neko088.jpg
try {
var b64content = fs.readFileSync(img, { encoding: "base64" });
} catch (e) {
console.log(e);
}
twt.post("media/upload", { media_data: b64content }, function(
err,
data,
response
) {
console.log(data);
});
}
setInterval(() => {
twtRandomNeko();
}, config.intervals.neko);
I searched on google, found no solution, tried some ways. I also thought about making a temporary folder, but before continuing, I decided to bring up this issue, I would be very grateful if someone helped me :)