'how do i check if hits has a value or not?

My goal is to send an alarm if the [hits] field is empty.

This is my result:

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

and this is my code:

const axios = require('axios');
const query = {
query: {
match: {
 "kubernetes.pod.name.keyword" : "fcppaddy-596b798c77-9hwbh"
      }
     }
    };
 axios.get("https://tommaso.fachin:[email protected]:9200/filebeat-7.15.2/_search? 
 pretty", query)
  .then((res) => {
    console.log(res.data);
    console.log(res.status);
console.log(JSON.stringify(res.data));
  });


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source