@hookcompany/feathers-client-custom-methods
Version:
️🏹 Create feathers service on client with custom methods names.
116 lines (73 loc) • 2.53 kB
Markdown
[](http://badge.fury.io/js/%40hookcompany%2Ffeathers-client-custom-methods)
[](https://nodei.co/npm/@hookcompany%2Ffeathers-client-custom-methods.png?downloads=true)
Use npm:
```sh
npm install --save @hookcompany/feathers-client-custom-methods
```
Or use yarn:
```sh
yarn add @hookcompany/feathers-client-custom-methods
```
Install @hookcompany/feathers-custom-methods on server ([Fathers Custom Methods](https://www.npmjs.com/package/@hookcompany/feathers-custom-methods))
## Config
#### Bootstrap
```javascript
import feathers from '@feathersjs/feathers';
import feathersRestClient from '@feathersjs/rest-client';
import axios from 'axios';
import feathersCustomMethods from '@hookcompany/feathers-client-custom-methods';
const HTTP_URI = '<endPoint>';
const rest = feathers()
.configure(feathersRestClient(HTTP_URI).axios(axios));
feathersCustomMethods.bootstrap(rest)
.then(Feathers => {
const Feeds = Feathers.service('feeds');
Feeds.foo()
.then(console.log)
.catch(console.log);
});
```
```javascript
import feathers from '@feathersjs/feathers';
import feathersRestClient from '@feathersjs/rest-client';
import axios from 'axios';
import feathersCustomMethods from '@hookcompany/feathers-client-custom-methods';
const HTTP_URI = '<endPoint>';
const rest = feathers()
.configure(feathersRestClient(HTTP_URI).axios(axios))
.configure(feathersCustomMethods());
const Feeds = rest.service('feeds', [
'foo:find',
'bar:find',
'buzz:get',
'foobar:create',
'foobuzz:update',
'barbuzz:patch',
'foobarbuzz:remove'
]);
Feeds.foo()
.then(console.log)
.catch(console.log);
```
You can consume the service methods, like that:
[] localhost:3030/users/foo
[] localhost:3030/users/bar
[] localhost:3030/users/buzz/:id
[] localhost:3030/users/foobar
[] localhost:3030/users/foobuzz/:id
[] localhost:3030/users/barbuzz/:id
[] localhost:3030/users/foobarbuzz/:id