Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

359
Visualizações
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 Respostas
Responde à pergunta

0

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

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda