web-client

A simple web client utility.

npm install web-client
1 downloads in the last day
3 downloads in the last week
6 downloads in the last month

web-client

A simple web client utility.

Example GET

var webClient = require("web-client");

var webRequest = {};
webRequest.url = "https://duckduckgo.com/?q=http";
webRequest.method = "GET";
webRequest.headers = { "Accept": "text/html" };

var webMethod = webClient.webMethod();
webMethod.invoke(webRequest, function(err, webResponse) {
    if(err) { return console.log(err); }
    console.log("statusCode:", webResponse.statusCode);
    console.log("headers:", webResponse.headers);
    console.log("body:", webResponse.body);
});

Example POST

var webClient = require("web-client");

var webRequest = {};
webRequest.url = "https://duckduckgo.com/?q=http";
webRequest.method = "POST";
webRequest.headers = { "Accept": "text/html" };
webRequest.body = "sample body...will be ignored by this particular example!";

var webMethod = webClient.webMethod();
webMethod.invoke(webRequest, function(err, webResponse) {
    if(err) { return console.log(err); }
    console.log("statusCode:", webResponse.statusCode);
    console.log("headers:", webResponse.headers);
    console.log("body:", webResponse.body);
});
npm loves you