@poseidoncoder/pls

1.0.0 • Public • Published

pls

makes requests simple

an asynchronous, simple, promise-based HTTP request API

examples

GET request

const pls = require("pls")
pls.get("https://jsonplaceholder.typicode.com/todos/1")
    .then(response=> response.parse()) // returns reponse promise
    .then(body=> console.log(body)) // prints response to console
    .catch(error=> console.log(error)) // log error if there is an error

POST request

const pls = require("pls")
pls.post("https://jsonplaceholder.typicode.com/posts", "Hello World!", {"Content-type": "text/plain"})
    .then(response => response.parse()) // returns reponse promise
    .then(body => console.log(body)) // prints response to console
    .catch(error => console.log(error)) // log error if there is an error

methods

pls

pls.get(endpoint: string): Promise<Response>
pls.post(endpoint: string, payload: any, headers: http.OutgoingHttpHeaders): Promise<Response>

Response

Response.parse(): Promise<any>

Readme

Keywords

Package Sidebar

Install

npm i @poseidoncoder/pls

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

43.1 kB

Total Files

16

Last publish

Collaborators

  • poseidoncoder