I've been using a lot on a recent HAPI API development. I have just gone into my first real problem, perhaps my understanding or innocence have stumped me.
What I'm facing in the following code: -
Promise promise = required ('bluebird'), stuff is required ('../ / material'); Module.exports = {getSomething: function (request, answer) {var p = Promise.resolve (); P = p.then (function () {returns db.find () // etc etc}}}); P = p.then (function (resultFromPromise) {// Problem starts var data = accessories. Some relabel and boring function (resultant published); return data;}); P.then (function (data) {// no data here.}); }; };
I have commented on when problems usually start. stuff.doSomeReallyLongAndBoringFunction ()
returns an object response (interactively with more promises) and I want to access this object, but // no data here
Always sets fire to data before return stuff.doSomeReallyLongAndBoringFunction ()
continues to run and complete successfully regardless, but after the code goes async, I do not know that the function How to Return the Return Value of Does.
Anyone offering any guidance?
NB For just clarity, NB ) stuff.doSomeReallyLongAndBoringFunction (forever help is appreciated, please
does not return any promise though, I tried new promise back (reject, resolve) {});
Manual rap This is the only function that promises to successfully obtain data (successfully).
Update 1 stuff.doSomeReallyLongAndBoringFunction ()
is too big to post directly, but it does something like this: -
var promise = required ('bluebird'), RP = is required ('request-wired'); Module.exports = {doSomeReallyLongAndBoringFunction: function () {var p = Promise.resolve (); P = p.then (function () {returns db.find () // etc etc}}}); P.then (function (). (Function (feedback) {// Get some data from remote location}}. (Function (dataFromService)) {// Some jogzi pockers with some data var marshalledData = F (work (mistake, rescued) {return martialdata}};});}) hold (function (mistake) {}};};};
update 2 Thanks for your help, here is the real code, maybe it can be helpful?
Promise .resolve () .then (function ( ) {If (typesof utils.intTryParse (place)! == 'number') {return foursquare.createPlaceFoursquare (SS , Place, request, reply);} and {return {place: {placeID: place}}}}}. Then (function (place obj) {console.log ('set as place', placeObj); // always undefined, despite completion of the Aspen op;});
doSomeReallyLongAndBoringFunction
is running asynchronously, then it does not seem to run the way to install it. Edit - This is a simple description of how your code runs versus a revised version. It has been simplified, so you will need to fill the sections related to your actual implementation.
var promise = requirement ('bluebird'); Function myAsync () {setTimeout (function () {return is sleeping;}, 2000); }; // The way your code is running, Promise.resolve (). Then (function () {return 'hello';}) .then (function (done) {console.log (done); return myAsync (); // error is here}). Then (function (done) {console.log (done);}); // Recycled Promise .resolve () Then (work () (return 'hello';}) then (task (done) {console.log ()); new promise back (work (solution) {setTimeout (function () (solved) ');}, 2000);});}). Then (function (done) {console.log (done);});
No comments:
Post a Comment