npm.io
1.2.2 • Published 8 years ago

stackerjs-http

Licence
Version
1.2.2
Deps
4
Size
208 kB
Vulns
24
Weekly
0
Stars
1

Travis Test Coverage Maintainability dependencies Status npm

NPM

StackerJS

Http

Package for managing Http requests and responses in and outside StackerJS

Usage

Response

import { Http } from "stackerjs-http";

let httpResponse = new Http.Response();

httpResponse.setContent({ status: true });
httpResponse.setContent("Everything is ok"); // or
httpResponse.setContent(new Buffer("Something")); // or

httpResponse.setStatusCode(200);
MakeRequest
new Http.MakeRequest()
  .setPort(3000)
  .setHeader("Authorization", "Bearer some-token")
  .get("/v1/some/api", { limit: 10 }) // same for post(), put(), delete() or patch()
  .then(httpResponse => {
    // instance of Http.Response
    let content = httpResponse.getContent();
  });