This package has been deprecated

Author message:

Package no longer supported. Contact support@npmjs.com for more info.

fetchware-base-url

1.0.2 • Public • Published

fetchware-base-url

npm version build status coverage status dependencies

Prefixes all fetched urls with specified value without changes to fetch api

Installation

npm install --save fetchware-base-url

Usage

Here is an example of usage with isomorphic-fetch.

const baseUrl = require('fetchware-base-url')
const isomorphicFetch = require('isomorphic-fetch') //or use your favorite fetch implementation

const fetch = baseUrl('http://github.com')(isomorphicFetch)

fetch('/ct0r').then(response => ...) //request to http://github.com/ct0r

Custom parameters

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

const baseUrl = require('fetchware-base-url')
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 = baseUrl('http://github.com')(fetch)

fetch('/ct0r', {method: 'POST'}, {log: true})

Licence

MIT

/fetchware-base-url/

    Package Sidebar

    Install

    npm i fetchware-base-url

    Weekly Downloads

    1

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • npm