[ASK] How to use Node JS ?

jaran

New member
Hello guys, on this month I was searching about all topics Node JS at google but none of all them didnt have any understand for me. Basically, Im on still learnng javascript and jquery. I want to make a script which is calling external url with some parameter via cross domain method then I want to retrieve the result. Is there anyone can show me how to make script like that?
I will appreciated for all your help. Anyway, thanks before.
 

admin

Administrator
Staff member
cURL will do what you require, I use it all the time.

Sent from my SM-T310 using Tapatalk
 

jaran

New member
DJB said:
cURL will do what you require, I use it all the time.

Sent from my SM-T310 using Tapatalk

Some people said if Node JS more fast than using CURL via PHP. Node JS has alot implement for web app likes big company Facebook.
 

weilrich

New member
Modulus has a good beginner's guide to node.js. They are also "a premier Node.js hosting platform that provides a complete technology stack for application developers. This includes custom SSL, WebSockets, MongoDB, statistics, and more. Signup is quick and free" (from the 'About' box on the web page: http://blog.modulus.io/absolute-beginners-guide-to-nodejs

I've used node.js for cross-domain file retrieval and, although a it is a little arcane, it is relatively easy to get running.
 

jaran

New member
weilrich said:
Modulus has a good beginner's guide to node.js. They are also "a premier Node.js hosting platform that provides a complete technology stack for application developers. This includes custom SSL, WebSockets, MongoDB, statistics, and more. Signup is quick and free" (from the 'About' box on the web page: http://blog.modulus.io/absolute-beginners-guide-to-nodejs

I've used node.js for cross-domain file retrieval and, although a it is a little arcane, it is relatively easy to get running.

Thanks. It look like good site to guide me for understanding of Node JS.
 

fouadChk

Member
jaran said:
Hello guys, on this month I was searching about all topics Node JS at google but none of all them didnt have any understand for me. Basically, Im on still learnng javascript and jquery. I want to make a script which is calling external url with some parameter via cross domain method then I want to retrieve the result. Is there anyone can show me how to make script like that?
I will appreciated for all your help. Anyway, thanks before.

Not sure if you still need this but here we go:
The code snippet bellow just retrieve Google's web page. It's trivial and self-explanatory. If you need more explanations, feel free to ask.
Code:
var http = require('http'),
 options = { 
  host: 'www.google.com',
  port: 80,
  path: "/",
  method: "GET",
  headers:{
    "Host" : 'www.google.com',
    "User-Agent" :	'Nodejs',
  }
};
	  
var request = http.request(options, function(res) {
       // console.log('STATUS:', res.statusCode);
       // console.log('HEADERS:', res.headers);
        res.setEncoding('utf8');
        res.on('data', function (chunk) { console.log('BODY:', chunk); });
   }).end();

Copy past the code above in let's say a get.js file then at your command line run it as follow:
Code:
node get.js

All the data will be dumped at your console. If you also want to see the sent headers comment out the adhoc line in the code.

Note: Of course you must have Node.js installed for this to work.

Good luck.