@poseidoncoder/pls

make requests simple

Usage no npm install needed!

<script type="module">
  import poseidoncoderPls from 'https://cdn.skypack.dev/@poseidoncoder/pls';
</script>

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>