feathers-fetch-service

1.0.0-beta.5 • Public • Published

Feathers Fetch Service

Easily create a Fetch Service for Feathersjs.

Installing

Installation with the npm install command:

$ npm install --save feathers-fetch-service

or with yarn command:

$ yarn add feathers-fetch-service

Example

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
}

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Package Sidebar

Install

npm i feathers-fetch-service

Weekly Downloads

3

Version

1.0.0-beta.5

License

MIT

Unpacked Size

136 kB

Total Files

20

Last publish

Collaborators

  • particle4dev