1.1.0 • Published 7 years ago
purdyrest-client v1.1.0
purdyrest
Super simple to use
purdyrequest is designed to be the simplest way to make http calls to servers that follow purdyrest RESTful conventions.
const purdyrest = require('purdyrest');
const { create } = purdyrest('http://my-purdyrest-server.ext');
create({ hello: 'world' });
Methods
Create
create(body)
const purdyrest = require('purdyrest');
const { create } = purdyrest('http://my-purdyrest-server.ext');
create({ foo: 'bar' });
Sends a POST
request to http://my-purdyrest-server.ext
with
{ foo: 'bar' }
as the body in JSON format.
Destroy
destroy(id)
const purdyrest = require('purdyrest');
const { destroy } = purdyrest('http://my-purdyrest-server.ext');
destroy('custom-id');
Sends a DELETE
request to http://my-purdyrest-server.ext/custom-id
.
Filter
filter(queryParams)
const purdyrest = require('purdyrest');
const { filter } = purdyrest('http://my-purdyrest-server.ext');
filter({ foo: 'bar' });
Sends a GET
request to http://my-purdyrest-server.ext?foo=bar
.
Find
find(id)
const purdyrest = require('purdyrest');
const { find } = purdyrest('http://my-purdyrest-server.ext');
find('custom-id');
Sends a GET
request to http://my-purdyrest-server.ext/custom=id
.
Replace
replace(id, body)
const purdyrest = require('purdyrest');
const { replace } = purdyrest('http://my-purdyrest-server.ext');
replace('custom-id', { foo: 'bar' });
Sends a PUT
request to http://my-purdyrest-server.ext/custom=id
with
{ foo: 'bar' }
as the body in JSON format.
Update
update(id, body)
const purdyrest = require('purdyrest');
const { update } = purdyrest('http://my-purdyrest-server.ext');
update('custom-id', { foo: 'bar' });
Sends a PATCH
request to http://my-purdyrest-server.ext/custom=id
with
{ foo: 'bar' }
as the body in JSON format.
1.1.0
7 years ago