Created
July 24, 2019 17:36
-
-
Save ConnectedReasoning/c06f39f34e04743ae74c6f4850f70735 to your computer and use it in GitHub Desktop.
fetch promise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return new Promise((resolve, reject) => { | |
fetch("/api/v1/principal", { | |
method: 'GET', | |
headers: { | |
'Content-Type': 'application/json', | |
'Authorization': 'Bearer ' + access_token, | |
} | |
}) | |
.then(result => { | |
console.log('success. The result is ', result); | |
resilve(result); | |
}).catch(error =>{ | |
console.log('fail. error is ', error); | |
reject(error); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment