0.0.1-alpha.0 • Published 5 years ago

profetch v0.0.1-alpha.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Profetch

Build Status npm package

A fetch wrapper which proxies cross-origin HTTP request intelligently.

Install

This package is published as es6 module, import it with webpack or else.

This package depends on an Express/Koa middleware node-profetch

Usage

Use it as fetch() API

profetch('http://api.someservice.com/someendpoint', {
  method: 'POST',
  body: JSON.stringify({ some: 'payload' }),
  headers: {
    'Content-Type': 'application/json'
  }
})
.then(async response => {
  const json = await response.json()
})

Use a filter() function to shake the json response

profetch('http://api.someservice.com/someendpoint?some=querystring')
.filter({
  error_code: 'number',
  error: 'string',
  result: [
    {
      someproperty: 'string'
    }
  ]
})

Contributing

Welcome to contributing, the guidelines are being drafted.

License

Licensed under the MIT license.