Giter Site home page Giter Site logo

imanabbasi / axios-fetch-adapter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from haverstack/axios-fetch-adapter

0.0 1.0 0.0 581 KB

An Axios adapter that uses native `fetch`. Useful for Cloudflare Workers and ServiceWorker environments.

License: MIT License

JavaScript 1.98% TypeScript 98.02%

axios-fetch-adapter's Introduction

axios-fetch-adapter

npm badge checks badge codecov badge license badge

An Axios adapter that uses native fetch. Useful for Cloudflare Workers and ServiceWorker environments.

Install

npm install @haverstack/axios-fetch-adapter

Use

import axios from "axios";
import fetchAdapter from "@haverstack/axios-fetch-adapter";

const client = axios.create({
  adapter: fetchAdapter
});

To use with the Square API:

import { Client, Environment } from "square";
import fetchAdapter from "@haverstack/axios-fetch-adapter";

const client = new Client({
  accessToken,
  environment,
  unstable_httpClientOptions: { adapter: fetchAdapter }
});

Development

# Run tests
npm run test

# Check tests, linting, and formatting
npm run check

# Fix linting and formatting
npm run fix

A Miniflare testing environment is used in order to simulate a Cloudflare Worker or a ServiceWorker. This testing environment is also useful because Node does not have a native implementation of fetch.

Acknowledgements

The code in this repo draws heavily from the following projects:

  • vespaiach/axios-fetch-adapter: Most of the initial code in this repo was copied from here. Licensed MIT.
  • axios/axios: Rather than import axios for this repo, the necessary types and utility functions were copied directly. Licensed MIT.

License

MIT

axios-fetch-adapter's People

Contributors

cuibonobo avatar

Watchers

 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.