Category : General Programming Toggle

[JQuery / Node.js] request JSON data

JQuery Code

var result;

$.get(‘request address‘,function(data){
       result = $.parseJSON(data);
       console.log(result)
});

reference
http://api.jquery.com/jquery.get/
http://api.jquery.com/jQuery.ajax/

Node.js Code

var request = require(‘request’);
var result;

request(‘request address‘,function(err,res,body){
       result = JSON.parse(body);
       console.log(result);
});

reference
https://github.com/mikeal/request

ShutDown