Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

109
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda