1.0.3 • Published 7 years ago

fetchware-console v1.0.3

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

fetchware-console

npm version build status coverage status dependencies

Log all fetch api calls to console without changes to api

Installation

npm install --save fetchware-console

Usage

Basic usage with default formatting status method url delay(ms)

const consoleLogger = require('fetchware-console')
const isomorphicFetch = require('isomorphic-fetch') //or use your favorite fetch implementation

const fetch = consoleLogger()(isomorphicFetch)

Custom format

const options = {
  format: (date, url, options, response, ms) => console.log()
}

const fetch = consoleLogger(options)(isomorphicFetch)

Custom parameters

Decorator passes all arguments to decorated function. Useful for decorator interaction.

const consoleLogger = require('fetchware-console')
const isomorphicFetch = require('isomorphic-fetch') //or use your favorite fetch implementation

const myFetchDecorator = fetch =>
  (url, options, {log}) => {
    if (log)
      console.log(url)

    return fetch(url, options)
  }

let fetch = myFetchDecorator(isomorphicFetch)
fetch = consoleLogger()(fetch)

fetch('http://github.com', {method: 'POST'}, {log: true})

Licence

MIT

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.1.0

7 years ago