njs-fetch
v1.1.1-rc.2
Published
fetch for node.js
Downloads
4
Readme
njs-fetch
fetch for node.js
examples
simple get request
var fetch = require("njs-fetch");
fetch("http://example.com").then(res => {
console.log(res.body);
})
advanced https request
var fetch = require("njs-fetch");
fetch({
hostname: 'encrypted.google.com',
port: 443,
path: '/',
method: 'GET'
}).then(res => {
console.log(res.body);
})
simple post request
var fetch = require("njs-fetch");
var postData = JSON.stringify({question: cool});
fetch({
hostname: 'www.test.com',
port: 80,
path: '/cool',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(postData)
}
}, postData).then(res => {
console.log(res.body);
})