Created
April 10, 2017 22:06
-
-
Save rayhon1014/934536f59f5340a663950c5bb57cae2f 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
// Wrap the $.getJSON() call to return a real Promise | |
// properly handling rejection with the available `.fail` method | |
var fetchJSON = function(url) { | |
return new Promise((resolve, reject) => { | |
$.getJSON(url) | |
.done((json) => resolve(json)) | |
.fail((xhr, status, err) => reject(status + err.message)); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment