I am trying to access [[Promise Results]] and save it as a variable. The end goal I just want the result from the .then statement and use it in other function. If there is another better way to do it please let me, I'm new to JavaScript, so it would be awesome if you could explain it to me than just dump code. Thanks is advance Here is the fetch request
function currentloginid() {
return fetch('http://localhost/gaq/api/api.php?action=userid', {
method: 'GET',
})
.then(function(response) {
return response.json();
})
.then(function(data) {
var userid = JSON.parse(data);
console.log(userid);
return userid;
})
}
The code below is when I console log the function in another function
Promise {<pending>}
__proto__: Promise
[[PromiseState]]: "fulfilled"
[[PromiseResult]]: 1