Can you include the code for // do http request & ...
? And what is the code if do http request fails? Another point: you don't need return res.json ..; Change to res.json...; Angel "Java" Lopez @ajlopez On Fri, Nov 21, 2014 at 6:40 AM, André Simões <[email protected]> wrote: > Hi. I'm trying to create a component in Node.js that consumes two external > APIs. > > The code of my component is something like: > > var api1 = require('./api1'); > var api2 = require('./api2'); > var component = { api1: api1, api2: api2 }; > module.exports = component; > -------------------- > > api1 is something like this: > > var api1 = { testFunc: function(stuff,callback){ // do http request & > callback(result) } } > module.exports = api1; > > -------------------- > > I've one endpoint on nodejs where i'm trying to use this component, like > this: > > var component = require('../../component'); > component.api1.testFunc(1, function(result) {return res.json(200, > result.data);}); > > -------------------- > > It works fine for the first time. On the second call i have no response > from server. > Newbie here. Can someone help me please? > > Thanks in advance > > -- > Job board: http://jobs.nodejs.org/ > New group rules: > https://gist.github.com/othiym23/9886289#file-moderation-policy-md > Old group rules: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/nodejs/43a91f03-1e4d-4aac-8c3a-55715ffe47d3%40googlegroups.com > <https://groups.google.com/d/msgid/nodejs/43a91f03-1e4d-4aac-8c3a-55715ffe47d3%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CAMs%2BDqKaTyDGLEW3Kt0pjGkxK_uJRs-nn2rZmL6whU-DhMSdxA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
