Skip to content

PoseidonCoder/pls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pls - makes requests simple

What is this?

pls is 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>

About

😵 dead simple requests

Topics

Resources

License

Stars

Watchers

Forks