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

100
Vistas
Axios json response is undefined

i am sending a request to opensea api and trying to log the trait data. an example of the entire response is in pastebin url. thank you for taking the time to review this. https://pastebin.com/ugQHjbn1

var axios = require("axios").default;

var r = {
    method: 'GET',
    url: 'https://api.opensea.io/api/v1/assets',
    params: { order_direction: 'desc', offset: '0', limit: '1', collection:`enter code here` 'brotchain' }
};

axios.request(r).then(function (response) {
    console.log(JSON.stringify(response.data.assets.token_id));
}).catch(function (error) {
    console.error(error);
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

your problem is that the assets inside the data is an array, basically, you can not do response.data.assets.token_id because there is no token_id on an Array [].

In order to display each one of the assets, you need to loop over the array and then show the asset info or whatever property inside of it.

here is your code showing all the token_id of each entry and their traits

note: in the future it will help to see the full response and act using the different structures that are defined there.

var r = {
  method: 'GET',
  url: 'https://api.opensea.io/api/v1/assets',
  params: {
    order_direction: 'desc',
    offset: '0',
    limit: '1',
    collection: 'brotchain'
  }
};

axios.request(r).then(response => {
  const assets = response.data.assets;

  assets.forEach(asset => {
    console.log("token id of the asset", asset.token_id);
    console.log("now we will show all the traits for this asset")
    console.log(asset.traits);
    console.log("end of the asset");
  })
}).catch(error => {
  console.error(error);
});
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>

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