Hi
Today I've started using q as a deferred/promises library and began reading some docs and writing a post with the following example
var xhr = new XMLHttpRequest();
function request(){
var def = Q.defer();
xhr.open('GET', 'data1.json');
xhr.send();
xhr.onreadystatechange = solver;
function solver(){
if (xhr.readyState === 4) {
if(xhr.status === 200){
def.resolve();
}else{
def.reject( new Error('Error message') );
}
}
}
return def.promise;
}
req = request();
req.then(function(){
console.log('done!');
},function(err){
console.log('fail!');
});
If the request is ok everything works as expected BUT if the request fails the console displays the following
Searching across the web, I found I can hide the [Q]'s messages putting something like
Q.stopUnhandledRejectionTracking();
at the top of file, but still do not figure out why is this message for.
How can I adapt my example to not show this message? or is totally normal this kind of message?