0.0.5 • Published 12 months ago

@round12/peach v0.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

Peach HTTP Client

Install

$ npm i @round12/peach

Create 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

MethodDescription
createCreate a peach instance with defaults configs
pathSets a custom path for a given resource. I'll be appended to the baseURL default config
cancellableMakes a cancellable request
querySets query parameters passing an object
getPerforms a GET request
postPerforms a POST request
putPerforms a PUT request
patchPerforms a PATCH request
deletePerforms a DELETE request
0.0.5

12 months ago

0.0.3

12 months ago