extract data from callback function javascript

Viewed 9

var price = getSteamItemPrice("AK-47 | Redline (Field-Tested)", 730); //returns undefined

function getSteamItemPrice(hash_name, appid) { 
    Fetcher.getItemPrice({
    market_hash_name: hash_name,
    appid: appid,
    callback: (err, price) => {
        if (err) throw err;

        callback(price);
    }
});

I am trying to extract the price to a variable outside the promise and I don't understand why the var is undefined.

0 Answers
Related