I am trying to create a node module to grab some posts but I am getting an undefined error.
Index.js
var request = require('request');
function getPosts() {
var options = {
url: 'https://myapi.com/posts.json',
headers: {
'User-Agent': 'request'
}
};
function callback(error, response, body) {
if (!error && response.statusCode == 200) {
return JSON.parse(body);
}
}
request(options, callback);
}
exports.posts = getPosts;
test/index.js
var should = require('chai').should(),
myModule = require('../index');
describe('Posts call', function () {
it('should return posts', function () {
myModule.posts().should.equal(100);
});
});
What am I missing?