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

237
Views
¿Cómo registraría los valores hash en esta respuesta API?

Soy nuevo en javascript y me preguntaba cómo accedería al valor hash y devolvería la cadena para poder registrarla. Aquí está mi código, estoy usando axios.

Aquí está mi código:

 client.on("messageCreate", (message) => { const args = message.content.slice(prefix.length).trim().split(' ') const command = args.shift().toLowerCase(); if (command === 'search') { let termargs = args.join(" "); const options = { method: 'GET', url: 'https://breachdirectory.p.rapidapi.com/', params: { func: 'auto', term: termargs}, headers: { 'x-rapidapi-host': 'breachdirectory.p.rapidapi.com', 'x-rapidapi-key': (keytouse, keys[keytouse]), } }; message.reply("searching...") options.params.term = termargs axios.request(options).then(function (response) { console.log('Found:' , response.data["result"]); }).catch(function (error) { message.reply(JSON.stringify(error)); }); } }); client.login(TOKEN);

Esto es lo que devuelve:

 Found: [ { has_password: false, sources: [ 'Pluto.tv' ] }, { has_password: true, password: 'bleh', hash: 'kMUX9351bsMjbgXH9rpKKf+GIYJrJy4=', sources: [ 'Aptoide.com' ] }, { has_password: true, password: 'blah', hash: 'lEiyXSecP9cIGJfyYhs8yteVEplUIRjAvaI7Jc76upI=', sources: [ 'Collection 1' ] }, { has_password: true, password: 'blahblahblah', hash: 'djdrICyb/EfH6+R0g/26+d+GIYJrJy6j', sources: 'Unverified' } ]

Intenté hacer response.data.results.hash pero eso no funcionó. Cualquier ayuda sería apreciada. ¡Gracias!

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

0

los resultados es una matriz por lo que:

 response.data.results[i].hash

que "i" es un número como 0,1,...

about 4 years ago · Juan Pablo Isaza Report

0

La respuesta parece ser una matriz de objetos, así que tal vez intente lanzar la respuesta en bucle y obtener el hash de cada objeto. P.EJ:

 axios.get('/user?ID=12345') .then(function (response) { response.data.forEach(item => { console.log(item.hash); }); })

Si esto no funciona, ¿podría compartir un archivo console.log() del objeto de respuesta?

El ejemplo de axios GET fue recuperado

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!