I'm having trouble sending a json file to the client and keep encountering internal errors (500). Can anyone assist me with this issue? Additionally, I am using Handlebars as my view engine.
Within app.js:
[...]
var APIconditions = {};
var APIhourly = {};
function retrieveWeatherData() {
var data = ['/conditionsWU.json', '/hourlyWU.json'];
request(data[0], function(err, res, body) {
if (!err && res.statusCode == 200) {
APIconditions = JSON.parse(body);
}
});
request(data[1], function(err, res, body) {
if (!err && res.statusCode == 200) {
APIhourly = JSON.parse(body);
}
});
}
[...]
In index.js:
[...]
router.get('/conditions' , function(req, res, next) {
res.json(APIconditions);
});
router.get('/hourly' , function(req, res, next) {
res.json(APIhourly);
});
[...]
As for client.js:
[...]
function retrieveWeather() {
var APIconditions = 'conditions';
var APIhourly = 'hourly';
$.getJSON(APIconditions, function (data) {
[...]
});
$.getJSON(APIhourly, function (data) {
[...]
});
[...]