http-get-json
Advanced tools
Comparing version 1.0.0 to 1.0.1
18
index.js
var http = require("http"); | ||
var httpGetJSON = (url, cb) => { | ||
http.get(url, res => { | ||
let result = []; | ||
res.setEncoding('utf8') | ||
.on('data', (chunk) => result.push(chunk)) | ||
var httpGetJSON = ( url, cb ) => | ||
http.get( url, res => ( chunks => | ||
res.setEncoding( "utf8" ) | ||
.on('data', chunk => chunks.push(chunk)) | ||
.on('end', () => { | ||
try { | ||
cb(null, JSON.parse(result.join(''))); | ||
cb(null, JSON.parse( chunks.join('') )); | ||
} catch (err) { cb(err); } | ||
}) | ||
}).on('error', cb); | ||
}; | ||
}))([])) | ||
.on('error', cb); | ||
module.exports = httpGetJSON; | ||
module.exports = httpGetJSON; |
{ | ||
"name": "http-get-json", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Give me the JSON", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
1025
12