I am attempting to get the return of a promise however I am getting undefined.
The promise
return new Promise((resolve, reject) => {
ajax(requestOptions).then((response) => {
const { jwt } = response;
run(() => {
resolve({ token: jwt });
});
}, (error) => {
run(() => {
reject(error);
});
});
});
Trying to get the value
this.get('session').authenticate(authenticator, credentials).then((response) => {
console.log(response);
}, (reason) => {
this.set('errorMessage', reason.error || JSON.stringify(reason));
});
The error returns just fine, however the response returns undefined. But if I print the response in the promise method it shows that it has a value.
Aucun commentaire:
Enregistrer un commentaire