Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created May 15, 2020 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/de0bf56699c3d0bae1b8c054f2bca86b to your computer and use it in GitHub Desktop.
Save bjoerntx/de0bf56699c3d0bae1b8c054f2bca86b to your computer and use it in GitHub Desktop.
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