GithubHelp home page GithubHelp logo

wsedlacek / axios-fetch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lifeomic/axios-fetch

0.0 1.0 0.0 1.7 MB

A WebAPI Fetch implementation backed by an Axios client

License: MIT License

JavaScript 100.00%

axios-fetch's Introduction

Axios-Fetch

Greenkeeper badge Build Status Coverage Status

This library exposes a Fetch WebAPI implementation backed by a Axios client instance. This allows a bridge between projects that have pre-configured Axios clients already to other libraries that require Fetch implementations.

One library that wants a Fetch implementation is the Apollo Link HTTP library. If your project has an existing Axios client configured, then this project can help you use that client in your apollo-link-http instance. Here is some sample code:

const { buildAxiosFetch } = require("@lifeomic/axios-fetch");
const { createHttpLink } = require("apollo-link-http");
const link = createHttpLink({
  uri: "/graphql"
  fetch: buildAxiosFetch(yourAxiosInstance)
});

Transforming requests

It is possible to transform requests before they reach your Axios client by providing an optional argument to buildAxiosFetch. For example, if you wanted a fetch implementation that always set the request timeout to 1 second, you could use code like:

const { buildAxiosFetch } = require("@lifeomic/axios-fetch");
const fetch = buildAxiosFetch(yourAxiosInstance, function (config) {
  config.timeout = 1000;
  return config;
});

Support for IE11

To Support IE11 add following dependencies

 npm install --save isomorphic-fetch
 npm install --save es6-promise

After adding these dependencies import in index.jsx file at top (Need to import before React)

import * as es6Promise from 'es6-promise';
import 'isomorphic-fetch';

es6Promise.polyfill(); // below all import end

axios-fetch's People

Contributors

mdlavin avatar greenkeeper[bot] avatar dependabot[bot] avatar joedimarzio avatar indigocarmen avatar hemp avatar dlannoye avatar jagoda avatar vikas-kumar56 avatar mlnchk avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.