'use strict';
var http = require('http');
var request = require('request');
exports.weatherWebhook = (req, res) => {
const host = 'http://api.openweathermap.org/';
const wwoApiKey = '7ffbb59524a81a6ac42ac3e942f68c5d';
var city = req.body.queryResult.parameters['geo-city'];
var path = 'data/2.5/weather?' +'APPID=' + wwoApiKey +'&q=' +city+'&units=imperial';
request(host+path,function(error,response,body)
{
var a=JSON.parse(body);
console.log(JSON.parse(body));
var temp=a.main.temp;
var location=a.name;
console.log(location);
res.json({ 'fulfillmentText': city });
});
};
Why do I get internal server error and how can I pass values to fulfillment text via resolve function?