node.js - Promise chain is not executed in nodejs -



node.js - Promise chain is not executed in nodejs -

i have next code:

q.fcall(-> response = req.post({url:url, formdata: formdata}) homecoming response ).then((response) -> reply(response) )

it makes request , when server response execute reply function, until here works fine. response in xml format:

<?xml version='1.0' encoding='utf-8'?> <foxydata> <store_version>2.0</store_version> <result>success</result> <messages> <message>transaction found</message> </messages> <transaction> ... ... ...

i want utilize node module(xml2js) convert it. done this:

add = (request, reply) -> q.fcall(-> response = req.post({url:url, formdata: formdata}) homecoming response ).then((response) -> parsexml(response, (err, result) -> reply(result) ) )

but in case reply executed immidiately , result empty. thought missing/doing wrong?

try using q.denodeify.

return q.denodeify(parsexml)(response);

you must homecoming resulting promise handler function result forwarded promise returned then.

node.js coffeescript

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -