Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

356
Views
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 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!