Error: h1.js:25 Warning: a promise was rejected with a non-error: [object String]
Not quite sure why, I would like to help understand the error and cause it. Still learning Promises and AJAX, so very grateful! (For example, as I write this, I also think it is a little redundant to promise an ajax object, but to be honest, I don't know how to rewrite it otherwise)
var logisticsModule = (function() { return { initialize: function() { dateTimeFxns.getReservedDates.then( // success function(reserved_dates) { console.log("success with value = " + reserved_dates) }, function(error) { console.log("error with value = " + error) } ) } } })(); var dateTimeFxns = { getReservedDates: new Promise( function(resolve, reject) { $.ajax({ // some url & data }) .done(function(result) { resolve(result) } .fail(function(error) { reject(error) } }) } $(document).ready(function() { logisticsModule.initialize(); })
The UPDATE warning message is saved when I have .fail as:
.fail(function(jqXHR, textStatus, errorThrown) { reject(new Error(errorThrown)) })
james source share