node-news
Advanced tools
Comparing version 0.0.3 to 0.0.4
17
index.js
@@ -15,3 +15,5 @@ var dotenv = require('dotenv').config(); | ||
callback = (typeof callback === 'function') ? callback : function() {}; | ||
if (!callback || typeof callback !== 'function') { | ||
return; | ||
} | ||
@@ -25,10 +27,11 @@ request | ||
callback = (typeof callback === 'function') ? callback : function() {}; | ||
if(typeof params === 'function') { | ||
// throw error | ||
callback = params; | ||
callback(new Error('Missing the params object')); | ||
} | ||
// TODO: look at this error | ||
if(typeof params === 'function' || params.length === 0) { | ||
if(!params.source) { | ||
// throw error | ||
console.log('Missing the params object'); | ||
callback({error: 'Missing the params object'}); | ||
return; | ||
callback(new Error('source is a required')); | ||
} | ||
@@ -35,0 +38,0 @@ |
{ | ||
"name": "node-news", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "news api", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -19,3 +19,3 @@ var News = require('./index.js'); | ||
news.getSoures(function(err, res){ | ||
news.getSources(function(err, res){ | ||
@@ -47,7 +47,10 @@ var response = res.body; | ||
var params = { | ||
source: 'cnn', | ||
// source: 'cnn', | ||
sortBy: 'popular', | ||
}; | ||
news.getArticles(params ,function(err, res){ | ||
news.getArticles(function(err, res){ | ||
console.log(err); | ||
var response = res.body; | ||
@@ -54,0 +57,0 @@ |
94
4637