Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!