@poseidoncoder/pls
v1.0.0
Published
make requests simple
Downloads
1
Readme
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>