Hi i am currently trying to fetch json data from an api using slash commands but it keeps erroring

const { EmbedBuilder, PermissionsBitField } = require("discord.js");
const { SlashCommandBuilder } = require("@discordjs/builders");
const axios = require('axios');

// Guide: https://discordjs.guide/slash-commands/advanced-creation.html

module.exports = {
data: new SlashCommandBuilder()
.setName("test")
.setDescription("test"),

run: async (client, interaction) => {

axios
.get('')
.then((res) => {
console.log("RES:" , res.data)

const exampleEmbed = new EmbedBuilder()
.setColor(0xff0000)
.setTitle('test ')
.setDescription(res.data)

interaction.reply({ embeds: [exampleEmbed] });
})
}
};
const { EmbedBuilder, PermissionsBitField } = require("discord.js");
const { SlashCommandBuilder } = require("@discordjs/builders");
const axios = require('axios');

// Guide: https://discordjs.guide/slash-commands/advanced-creation.html

module.exports = {
data: new SlashCommandBuilder()
.setName("test")
.setDescription("test"),

run: async (client, interaction) => {

axios
.get('')
.then((res) => {
console.log("RES:" , res.data)

const exampleEmbed = new EmbedBuilder()
.setColor(0xff0000)
.setTitle('test ')
.setDescription(res.data)

interaction.reply({ embeds: [exampleEmbed] });
})
}
};
8 Replies
d.js toolkit
d.js toolkit10mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
v.dll
v.dllOP10mo ago
treble/luna
treble/luna10mo ago
and that error is also update djs
v.dll
v.dllOP10mo ago
No description
treble/luna
treble/luna10mo ago
your api is returning an object, not a string. Not djs related but still update because 14.7 is broken
v.dll
v.dllOP10mo ago
ok ok so shall i convert it into a string or im fairly new to js
treble/luna
treble/luna10mo ago
yes. Also, a basic js knowledge is required for djs
v.dll
v.dllOP10mo ago
Yeah im kinda rushing into it all but i have some sort of a grasp ty anyway
Want results from more Discord servers?
Add your server