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

132
Vistas
How to create a list out of a json array

What i need to do is console.log all ip adresses and objects inside services and i have no idea what to do my current code is

    fetch('https://search.censys.io/api/v2/hosts/search?q=' + option1 + '&per_page=' + option2 + '&virtual_hosts=' + option3, fetchauth)
    .then(response => response.json())
    .then(response => console.log(response.result.hits[0].ip))
    .catch(err => console.error(err));

sample API response

https://pastebin.com/s7k2YLG5

Im planing to display these informations inside a discord embed

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can use Array.map() to get list of IPs:

response.result.hits.map(item => item.ip)

const response = {
  "code": 200,
  "status": "OK",
  "result": {
    "query": "query",
    "total": 34,
    "duration": 1245,
    "hits": [
      {
        "ip": "x.x.x.x",
        "services": [
          {
            "port": 21,
            "service_name": "FTP",
            "transport_protocol": "TCP"
          },
          {
            "port": 22,
            "service_name": "SSH",
            "transport_protocol": "TCP"
          },
        ]
      },
      {
        "ip": "y.y.y.y",
        "services": [
          {
            "port": 80,
            "service_name": "HTTP",
            "transport_protocol": "TCP"
          },
          {
            "port": 443,
            "service_name": "HTTP",
            "certificate": "c3ea28c3a4eaa4075c45bb3740dd4207af099727eb654b974bb0b2a5703406b2",
            "transport_protocol": "TCP"
          }
        ],
        "location": {
          "continent": "Europe",
          "country": "France",
          "country_code": "FR",
          "timezone": "Europe/Paris",
          "coordinates": {
            "latitude": 48.8582,
            "longitude": 2.3387
          },
          "registered_country": "France",
          "registered_country_code": "FR"
        },
        "autonomous_system": {
          "asn": 16276,
          "description": "OVH",
          "bgp_prefix": "51.38.0.0/16",
          "name": "OVH",
          "country_code": "FR"
        },
        "last_updated_at": "2022-07-29T12:59:03.142Z"
      }
]
}
};

console.log(response.result.hits.map(a=>a.ip));

about 4 years ago · Santiago Trujillo 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