@round12/peach
v0.0.5
Published
Build HTTP powerful and requests
Maintainers
Readme
Peach HTTP Client
Install
$ npm i @round12/peachCreate an instance
import peach from 'peach'
const http = peach.create({
baseURL: 'https://some-domain.com/api'
})Do a request
GET
http.get()
http.get('data.some.key')POST
http.post(payload)PUT
http.put(payload)PATCH
http.path(id).patch(payload)
http.patch(payload, id)DELETE
http.path(id).delete()
http.delete(id)Cancellable Requests
http.cancellable('someUniqKey').get()Query parameters
http.query({ limit: 10, offset: 4 }).get()API Reference
| Method | Description |
| ------------- | --------------------------------------------------------------------------------------- |
| create | Create a peach instance with defaults configs |
| path | Sets a custom path for a given resource. I'll be appended to the baseURL default config |
| cancellable | Makes a cancellable request |
| query | Sets query parameters passing an object |
| get | Performs a GET request |
| post | Performs a POST request |
| put | Performs a PUT request |
| patch | Performs a PATCH request |
| delete | Performs a DELETE request |
