Easily create a Fetch Service for Feathersjs.
Installation with the npm install command:
$ npm install --save feathers-fetch-service
or with yarn command:
$ yarn add feathers-fetch-service
Here's a complete example of a Feathers server with a fetch service.
$ npm install --save feathers-fetch-service
Create a service.
import FetchService from 'feathers-fetch-service'
const notificationsService = new FetchService({
name: '',
options: {},
base: 'http://notification.dev.awesome-app.com',
})
Then you can send http request with nice API:
async function getNotifications(limit = 5, skip) {
const query = {
$limit: limit,
$sort: {
createdAt: -1,
},
}
if (skip) {
query.$skip = skip
}
const data = await notificationsService.find({
query,
})
return data
}
async function createComment(story, content, comment, { req }) {
const data = await storiesService.create({
story,
content,
comment,
createdAt: new Date(),
}, {
headers: req.headers,
})
return data
}
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Nam Hoang - Initial work - particle4dev
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details