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

231
Vistas
How would I log the hash values in this API response?

I'm new to javascript and I was wondering how I would access the hash value and return the string so I can log it? Here's my code, I'm using axios.

Here's my code:

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);

Here's what it returns:

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'
      }
    ]

I tried doing response.data.results.hash but that didn't work. Any help would be appreciated. Thank you!

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

the results is an array so :

response.data.results[i].hash

that "i" is a number like 0,1,...

about 4 years ago · Juan Pablo Isaza Denunciar

0

The response seems to be an array of objects, so maybe try looping throw the response and get the hash of each object. E.G:

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

If this doesn't work could you please share a console.log() of the response object?

The axios GET example was recover

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