Created
May 15, 2020 10:49
-
-
Save bjoerntx/de0bf56699c3d0bae1b8c054f2bca86b to your computer and use it in GitHub Desktop.
This file contains 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
async function callEndpoint(serviceURL) { | |
return new Promise(resolve => { | |
$.ajax({ | |
type: "GET", | |
url: serviceURL, | |
contentType: 'application/json', | |
success: successFunc, | |
error: errorFunc | |
}); | |
function successFunc(data, status) { | |
resolve(data); | |
} | |
function errorFunc(data) { | |
throw "Request failed. Please try again later."; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment