Skip to content

Instantly share code, notes, and snippets.

@ConnectedReasoning
Created July 24, 2019 17:36
Show Gist options
  • Save ConnectedReasoning/c06f39f34e04743ae74c6f4850f70735 to your computer and use it in GitHub Desktop.
Save ConnectedReasoning/c06f39f34e04743ae74c6f4850f70735 to your computer and use it in GitHub Desktop.
fetch promise
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