I'm developing a discord bot that has a command which randomly generates images of cats.
This is my code:
else if(command === 'kitteh') {
fetch('https://api.thecatapi.com/v1/images/search?format=json', {
headers: {
'x-api-key' : 'MY_API_KEY',
}
})
.then(
function(response) {
response.json().then(function(data) {
const embed = new Discord.MessageEmbed()
console.log(data.url)
.setTitle('kitteh :cat:')
.setImage(data.url)
.setFooter(`${message.author.tag} | powered by TheCatAPI (thecatapi.com)`);
message.channel.send(embed);
});
}
);
For some reason, the api does not send me the url of the image, and the console prints undefined, and the discord bot shows no image.