Monday, 1 May 2017

Wrapping/intercepting a promise in an inner function

I'm having difficulty finding an answer to my question, perhaps because I don't know how to ask it (what search terms to use). I'm really struggling to understand promises, and have watched a number of tutorial videos and am still not getting some fundamental piece to make it click.

In Node, I am using the request-promise module, which returns a promise when I make a call to an rp() method. I am calling return rp(service); from within a function. But what I want to do, instead, is add a .then() handler to this to do some post-processing with the result of the service call, BEFORE returning the promise back to the caller so the caller can still have its own then handler.

How do I accomplish this?



via user1588877

No comments:

Post a Comment