Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodejs: not going in to the requestify

Tags:

node.js

When I tried to get the response from the requested URL, I can get only printed statements of 'out' its not going in the requestify and how to get the response from requestify. Can any one tell me what is the error behind this.

console.log('out');
requestify.get('http://www.google.com').then(function(response) {
// Get the response body
console.log('in');
response.getBody();
console.log(response.body);
});
console.log('out');
like image 538
VG__ Avatar asked Mar 13 '26 07:03

VG__


1 Answers

Did you add

var requestify = require('requestify'); 

above your code?

Also, due to the async behavior of NodeJS it will probably first display 'out' twice and after you recieved a response from Google it will display the google homepage HTML.

like image 138
Guy Hagemans Avatar answered Mar 17 '26 04:03

Guy Hagemans