2

I'm stuck I use financial API, however I can't comprehend how to get that information to render on the page. I need to get to price in the profile and vol Avg. Please help.

That's what I use, I am able to console log data.body which returns the nested object.

data {
  symbol: 'AAPL',
  profile: {
    price: 291.45,
    beta: '1.139593',
    volAvg: '36724977',
    mktCap: '1345844630130.00',
    lastDiv: '2.92',
    range: '142-233.47',
    changes: -0.75,
    changesPercentage: '(-0.25%)',
    companyName: 'Apple Inc.',
    exchange: 'Nasdaq Global Select',
    industry: 'Computer Hardware',
    website: 'http://www.apple.com',
    description: 'Apple Inc is designs, manufactures and markets mobile communication and media devices and personal computers, and sells a variety of related software, services, accessories, networking solutions and third-party digital content and applications.',
    ceo: 'Timothy D. Cook',
    sector: 'Technology',
    image: 'https://financialmodelingprep.com/images-New-jpg/AAPL.jpg'
  }
}



 app.post('/search', (req, res) => {
   superagent.get(`https://financialmodelingprep.com/api/v3/company/profile/AAPL`).then(data => {       

    const companyData = data.body.map(company => new Company(company));
    // console.log(data, companyData);
    res.render('/search', { companyData });
   }).catch(error => {
   res.render('error', { error });
   });
   });
1
  • There is no body property on the data object that’s why you can’t use it. Commented Dec 31, 2019 at 12:37

1 Answer 1

2

You can access the price with data.profile.price and the avgvol with data.profile.volAvg

Don't forget to add what it's contained in, which in this case I guess is companyData

companyData.data.profile.price

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.