https://github.com/poseidoncoder/pls
😵 dead simple requests
https://github.com/poseidoncoder/pls
ajax simple typescript
Last synced: 8 months ago
JSON representation
😵 dead simple requests
- Host: GitHub
- URL: https://github.com/poseidoncoder/pls
- Owner: PoseidonCoder
- License: gpl-3.0
- Created: 2020-09-27T19:30:30.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-02-23T18:26:57.000Z (about 5 years ago)
- Last Synced: 2025-06-16T01:19:56.105Z (9 months ago)
- Topics: ajax, simple, typescript
- Language: TypeScript
- Homepage:
- Size: 24.4 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pls - makes requests simple
## What is this?
pls is an asynchronous, simple, [promise](https://developer.mozilla.org/enUS/docs/Web/JavaScript/Reference/Global_Objects/Promise)-based HTTP request API
## examples
### GET request
```js
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
```js
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
```ts
pls.get(endpoint: string): Promise
```
```ts
pls.post(endpoint: string, payload: any, headers: http.OutgoingHttpHeaders): Promise
```
### Response
```ts
Response.parse(): Promise
```