Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

362
Vistas
I tried to handle an Axios error. It doesn't work, how to handle it correctly?

I'm making a Discord bot, now I'm working at commands that interact with Geometry Dash API. I'm using axios to fetch the level info, and when I type the existing ID, I get the correct and working result. But if I'll type the incorrect ID, I get a -1 error. I tried to handle this error, but nothing works. What should I do?

const axios = require("axios");
exports.run = (client, message, args) => {
  const id = args[0];
  axios.get(`https://gdbrowser.com/api/level/${id}`).then((response) => {
    try {
    const { data } = response;
    const { name, id, description, author, difficulty, downloads, length, stars, orbs, diamonds, featured, epic, gameVersion, version, coins, verifiedCoins, starsRequested, ldm, objects } = data;
    message.channel.send(`Name: ${name}\nID: ${id}\nDesc: ${description}\nAuthor: ${author}\nDifficulty: ${difficulty}\nDownloads: ${downloads}\nLength: ${length}\nStars: ${stars}\nOrbs: ${orbs}\nDiamonds: ${diamonds}\nFeatured: ${featured}\nEpic: ${epic}\nGame Ver: ${gameVersion}\nVersion: ${version}\nCoins: ${coins}\nVerified Coins: ${verifiedCoins}\nStarsReq: ${starsRequested}\nLDM: ${ldm}\nObjects: ${objects}`)
    } catch (e) {
      if(data === -1) {
      return;
      }
    }
  })
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Already fixed it. -1 was the error.response.data.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda