Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Promise deferred
function getSomeJSON(url, callback) {
// AJAX call to get data from server. Accepts callback and calls
// with callback(err, response)
function fetchJSON(url) {
var deferred = new Deferred();
getSomeJSON(url, function (err, response) {
if (err) return deferred.reject(err);
return deferred.promise;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment