Friday, 26 May 2017

Passing GET reponse Body into Variable in Nodejs

I need to set response data to context.forecast. I tried by using GET method inside the if loop but context becomes undefined. is there a way to define GET function outside and just call to get the value into data variable?

Note: the location variable need to be passed into GET URL

getForecast({context, entities}) {
    var location = firstEntityValue(entities, 'location');
    if (location) {
      delete context.missingLocation;
      //TODO
      //var data = GET URL
        context.forecast = data
      })
    } else {
      context.missingLocation = true;
      delete context.forecast;
    }
    return context;
  }



via Karthikeyan Prakash

No comments:

Post a Comment