forked from vivekgs2007/node-googleNewsAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdummy.js
More file actions
23 lines (22 loc) · 710 Bytes
/
dummy.js
File metadata and controls
23 lines (22 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var http = require('http');
function Restapi () {
this.curlCall = function(req,res){
var search = req.query.search;
var url = 'http://ajax.googleapis.com/ajax/services/search/news?v=1.0&q='+search;
http.get(url, this.collectData);
}
this.collectData = function(req,res){
res.setEncoding('utf8');
res.on('data', function(d) {
responseBody = d;
});
res.on('end', function(request,response) {
var responseEnd = JSON.parse(responseBody);
console.log(responseEnd);
return response.render('index', {
title: 'Index Page'
});
});
}
}
module.exports = Restapi;