Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shallinta/ajax-fetch-esm
An esm ajax module based on Fetch API, with interceptors. This ajax module is for those environments which do not support CommonJS modules, such as vite.
https://github.com/shallinta/ajax-fetch-esm
ajax esm fetch fetchapi interceptor typescript vite vue3
Last synced: about 1 month ago
JSON representation
An esm ajax module based on Fetch API, with interceptors. This ajax module is for those environments which do not support CommonJS modules, such as vite.
- Host: GitHub
- URL: https://github.com/shallinta/ajax-fetch-esm
- Owner: shallinta
- License: mit
- Created: 2020-05-26T08:29:11.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-26T19:04:27.000Z (almost 3 years ago)
- Last Synced: 2024-11-05T00:06:38.633Z (about 2 months ago)
- Topics: ajax, esm, fetch, fetchapi, interceptor, typescript, vite, vue3
- Language: TypeScript
- Homepage:
- Size: 297 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# AjaxFetch (esm)
[![npm package](https://img.shields.io/npm/v/ajax-fetch-esm.svg)](https://www.npmjs.org/package/ajax-fetch-esm)
[![npm download](https://img.shields.io/npm/dt/ajax-fetch-esm.svg)](https://www.npmjs.org/package/ajax-fetch-esm)
[![github license](https://img.shields.io/github/license/shallinta/ajax-fetch-esm.svg)](https://github.com/shallinta/ajax-fetch-esm/blob/master/LICENSE)
[![github issues open](https://img.shields.io/github/issues/shallinta/ajax-fetch-esm.svg)](https://github.com/shallinta/ajax-fetch-esm/issues?q=is%3Aopen+is%3Aissue)
[![github issues closed](https://img.shields.io/github/issues-closed/shallinta/ajax-fetch-esm.svg)](https://github.com/shallinta/ajax-fetch-esm/issues?q=is%3Aissue+is%3Aclosed)
![github language top](https://img.shields.io/github/languages/top/shallinta/ajax-fetch-esm.svg)
[![github stars](https://img.shields.io/github/stars/shallinta/ajax-fetch-esm.svg?style=social&label=Stars)](https://github.com/shallinta/ajax-fetch-esm)[![NPM](https://nodei.co/npm/ajax-fetch-esm.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/ajax-fetch-esm)
> An **esm** ajax module based on [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), with **interceptors**. This ajax module is for those environments which do not support CommonJS modules, such as [vite](https://github.com/vuejs/vite).
## Install
```sh
npm install --save ajax-fetch-esm
```## Features
- [x] Basicaly ajax functions, such as `get`, `post`, etc.
- [x] Esm support.
- [x] Typescript support.
- [x] Based on [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).
- [x] No third-party dependencies.
- [x] Singleton and multiple instances support.
- [x] Interceptors for both request and response. Use it just like axios interceptors.
- [ ] More axios-like api support.## Usage
```js
// use singleton ajaxFetch instance
import ajaxFetch from 'ajax-fetch-esm';
// add url prefix
ajaxFetch.interceptors.request.use((config) => ({ ...config, baseURL: '/api' }));
``````js
// use specific instance
import { AjaxFetch } from 'ajax-fetch-esm';const ajaxFetchInstance = AjaxFetch.of();
ajaxFetchInstance.interceptors.request.use((config) => ({ ...config, baseURL: '/api' }));
export default ajaxFetchInstance;
```## Recently updated
See [CHANGELOG](CHANGELOG.md).
## Contribute to this
If you'd like to perfect `AjaxFetch` and implement more axios-like api based on Fetch API, feel free contributing to this repository. I have no requirement for this, as long as it is correct. Looking forward to your PRs.