AJAX Helper for NodeJS, instead of jQuery?

AJAX Helper for NodeJS, instead of jQuery?


I just want to do something like $.get/post on a server side script. Is there a better way instead of including the whole jQuery? I prefer not to use the messy get xml http requests stuff manually either.

Problem courtesy of: Jiew Meng


The equivalent to jquery.ajax in node.js is request

It sits on top of the node core http and makes things nicer to work with. Allowing for both callback and streaming requests.


var request = require('request');
request('http://www.google.com', function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body) // Print the google web page.

Solution courtesy of: generalhenry


Leave a Reply

Your email address will not be published. Required fields are marked *