I am creating a w / Express blog site and using Q for the first time, and I was hoping to use the knowledge of veteran Q users.
I make one query to my DB to load post data and another query that gets into the Instagram API (if it is not already cached) and returns some json. So I have something like:
Q.all([blogPromise, instagramPromise]).then(good, bad);
The problem / question that I am facing is that my request is not working in mine instagramPromise, and I am deferred.reject()calling, my function is being called bad. However, I still want to load the blog data page, if mine blogPromisepermits, but it seems that I do not get any arguments when the function is called bad(for example, I do not receive blogPromise data that was successfully delivered).
Given this, my only option is to not call deferred.reject()when I have an error, and instead call deferred.resolve()with something like deferred.resolve({error: true}), which I can then use in my function goodto handle what goes to my view.
So my question is: does this sound right? Isn't it an abuse of Q with help resolve, when in fact I ran into an error and should use reject? Or did I miss something with Q, which would allow a better fit?
source
share