I'm new to node (coming from python), and writing out some functions to grab data from an API as follows:const getAlertsForLine = (line) => { const url = 'http://...'; // some string formatting here, which is where line is used request(url, (error, response, body) => { const parsedBody = JSON.parse(body); let results = _.filter(parsedBody.alerts, (alert) => { return alert.severity === 'Minor'; }); return results; }); }; module.exports = { getAlertsForLine: getAlertsForLine }; Later, calling it like this:const utils = require('./src/utils'); let foo = utils.getAlertsForLine('Red'); results in foo being undefined. What am I missing here?
Submitted April 02, 2017 at 03:02PM by the_loop_is
No comments:
Post a Comment