Save response of GET request

Tell us what’s happening:

I’m using the request module to access the FCC API for stock prices. I created a custom function that accesses the API to get the latest price for the stock. I am able to console.log the price but can’t find anyway of using it. I tried returning it from my function (it’s undefined, or I can return the request object) or updating a global variable as suggested here (doesn’t work).

How do I change this function to make it return latestPrice?

Your code so far

function getPrice(name) {
    "" + name + "/quote",
    { json: true },
    (err, res, data) => {
      if (err) {
      price = data.latestPrice;


Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36.

Challenge: Stock Price Checker

Link to the challenge: