I have a problem getting or filling a variable within a promise.
the code is:
var _TOKEN = '';
client.metodoGet(clientId, clientSecret)
.then(function () {
_TOKEN = client.authentications["XXXXXXX"].accessToken;
console.log(_TOKEN);
this.token = _TOKEN;
return _TOKEN;
})
.catch(function (response) {
console.log(response);
});
and I need to get the token to be able to send this variable to another file.
As you see I declare the variable outside the method, and I give it a value within the method, but when printing, I always get undefined.
I hope you can help me.