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

108
Views
TypeError: no se pueden leer las propiedades de undefined (leyendo 'lista') al intentar hacer un comando de barra diagonal "urbana"

Mi comando urban-dictionary funciona bien como comando de texto común, pero cuando trato de hacer un comando de barra diagonal, mi código se rompe con TypeError: Cannot read properties of undefined (reading 'list') ! Aquí están mis options para el comando:

 "options": [ { "name": "search", "description": "Term to search for", "type": 3, "required": true } ]

y mi código de comando de barra:

 let query = interaction.options.getString('search') query = encodeURIComponent(query); const { data: { list }, } = axios.get(`https://api.urbandictionary.com/v0/define?term=${query}`).catch((err) => {}) const [answer] = list; const embed = new MessageEmbed() .setTitle(answer.word) .setURL(answer.permalink) .setColor("#380002") .setDescription(trim(answer.definition)) .addField("Example", trim(answer.example), false) .addField("Upvotes", `** ** ${answer.thumbs_up}`, true) .addField("Downvotes", `** ** ${answer.thumbs_down}`, true) .setFooter(`Author: ${answer.author}`); interaction.reply({embeds: [embed], ephemeral: false}).catch((err) => {})

Entonces, ¿alguna idea sobre lo que está mal? Si necesita más información, responderé en los comentarios porque no tengo idea de qué está mal.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

axios.get devuelve una Promise . Esto significa que axios.get(...).data no estará definido. La solución simple es agregar await :

 //async function const { data: { list }, } = await axios.get(`...`).catch((err) => {})
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!