1.0.0-beta.5 • Published 6 years ago

feathers-fetch-service v1.0.0-beta.5

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

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