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

229
Vistas
How can I console.log an individual attribute from a JSON payload object?

I am trying to console.log some JSON values from an OpeanSea api call payload. I can successfully hit the end point as seen in the console when I run this:

await fetch(`https://api.opensea.io/api/v1/collections?asset_owner=${currentAccount}&offset=0&limit=300`, options)
.then(response => response.json())
.then(response => console.log("collection owned by current address", response))

but when I try to log only one attribute from the response object:

await fetch(`https://api.opensea.io/api/v1/collections?asset_owner=${currentAccount}&offset=0&limit=300`, options)
  .then(response => response.json())
  .then(({ assetts }) => {
    assetts.forEach((attributes) => {
      console.log(attributes.name)
    })
  })

I see

TypeError: Cannot read properties of undefined (reading 'forEach')

Is

assetts

an arbitrary name to iterate through? I think this is what i dont understand

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

0

You should know the structure of json and target the required attributes. Like in your case its collections array which is array of object and each object contains name key so you can target key like:

await fetch(`https://api.opensea.io/api/v1/collections?asset_owner=${currentAccount}&offset=0&limit=300`, options)
    .then((response) => {
      return response.json();
    })
    .then((assetts) => {
      assetts.collections.forEach((attributes) => {
        console.log(attributes.name);
      });
    })
    .catch((error) => {
      console.log({ error });
    });

In your first then block you should have to return response after parsing it, if you want to use the parsed data in next then block.

Tip: It is a good practice if you also handle error by putting catch block after then block.

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