Home

Awesome

Apy

Build Status

Apy is a simple client-side library for making REST API AJAX calls. It supports both callback and promises.

API

all ([params], [callback])

Params

Returns

find (id, [params], [callback])

Params

Returns

save (data, [params], [callback])

Params

Returns

update (id, data, [params], [callback])

Params

Returns

destroy (id, [params], [callback])

Params

Returns

Examples

First define resource

var PeopleApi = new Apy({
    base: '/api/v3/people'
});

So let's fetch all nice developers

PeopleApi.all({ kind: 'nice', job: 'developer' }, function (err, data) {
    if (!err) {
        console.log(data);
    }
});

GET request to /api/v3/people/?kind=nice&job=developer

Or we can fetch all developers even if they are not nice...

PeopleApi.all().then((data) => {
    console.log(data);
}).catch((err) => {
    console.log(err);
});