Unable to return value from Promise.then javascript

Viewed 8663

I am using a Promise function to facilitate an ajax call. When I console log the 'value.bal' value from the server within the then function the expected value shows up in the console, but when I return it console.log it outside the then function the result is 'object Promise'. What am I missing?

    var promiseObject = SomefullfilledPromise;
    var result = promiseObject.then(function(value){
       console.log(value.bal); //expected value
       return value.bal;
    });
    console.log(result); //'object Promise'
1 Answers
var result = promiseObject.then(function(value){
       console.log(value.bal); //expected value
       return value.bal;
    });

would return a promise you can access the result of this promise in a .then()

.then((val) => {
    console.log(val)
})
Related