I don't know why I am getting this problem, I already have async included
here is the code
const fetch = require("node-fetch")
module.exports = {
name: "find",
aliases: ["f"],
run: async (message) => {
message.attachments.forEach((attachment) => {
const url = attachment.url;
console.log(url);
const res1 = await fetch(
`https://saucenao.com/search.php?db=999&output_type=2&testmode=1&numres=16&url=${url}`
);
const data1 = await res1.json();
console.log(data1);
});
},
};
CodePudding user response:
Try this
module.exports = {
name: "find",
aliases: ["f"],
run: async (message) => {
message.attachments.forEach(async (attachment) => {
const url = attachment.url;
console.log(url);
const res1 = await fetch(
`https://saucenao.com/search.php?db=999&output_type=2&testmode=1&numres=16&url=${url}`
);
const data1 = await res1.json();
console.log(data1);
});
},
};
async should be written in a function that has await method. In your code await is written in forEach function, not in the run.