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

138
Views
¿Cómo verifico si hits tiene un valor o no?

Mi objetivo es enviar una alarma si el campo [hits] está vacío.

Este es mi resultado:

 hits: { total: { value: 10000, relation: 'gte' }, max_score: 1, hits: [ [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object] ] } }

y este es mi codigo:

 const axios = require('axios'); const query = { query: { match: { "kubernetes.pod.name.keyword" : "fcppaddy-596b798c77-9hwbh" } } }; axios.get("https://tommaso.fachin:Indigestione!@elastic.gnet.it:9200/filebeat-7.15.2/_search? pretty", query) .then((res) => { console.log(res.data); console.log(res.status); console.log(JSON.stringify(res.data)); });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Todavía no estoy al 100%, pero según tus comentarios, parece que quieres verificar si hits tiene algo, y si es así, haz algo para cada uno:

 if(hits.length > 0) { hits.forEach((hit) => { triggerAlarm() }) }

Entonces, obviamente, puede elegir qué enviar como parámetro para triggerAlarm() , pero creo que esto es lo que está pidiendo

Editar, basado en su comentario:

 if(hits.hits.length > 0) { hits.forEach((hit) => { // for each item in hits.hits array, send mail ModuloMail() }) }
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!