GithubHelp home page GithubHelp logo

un-ts / x-fetch Goto Github PK

View Code? Open in Web Editor NEW
3.0 0.0 0.0 376 KB

A simple but elegant `fetch` API wrapper, use `fetch` like a charm

Home Page: https://xfetch.vercel.app

License: MIT License

JavaScript 0.83% TypeScript 99.17%
fetch fetch-api fetch-wrapper fetchapi fetcher ifetch

x-fetch's Introduction

x-fetch

GitHub Actions Codecov type-coverage npm GitHub Release

Conventional Commits Renovate enabled JavaScript Style Guide Code Style: Prettier changesets

A simple but elegant fetch API wrapper, use fetch like a charm

TOC

Usage

Install

# pnpm
pnpm add x-fetch

# yarn
yarn add x-fetch

# npm
npm i x-fetch

API

import { ApiMethod, createFetchApi, fetchApi, interceptors } from 'x-fetch'

// plain url, GET method
await fetchApi('url')

// with options, `method`, `body`, `query`, etc.
await fetchApi('url', {
  method: ApiMethod.POST, // or 'POST'
  // plain object or array, or BodyInit
  body: {},
  // URLSearchParametersOptions
  query: {
    key: 'value',
  },
  // json: boolean, // whether auto stringify body to json, default true for plain object or array, otherwise false
  // type: 'arrayBuffer' | 'blob' | 'json' | 'text' | null, `null` means plain `Response`
})

const interceptor: ApiInterceptor = (req, next) => {
  // do something with req
  const res = await next(req)
  // do something with res
  return res
}

// add interceptor
interceptors.use(interceptor)

// remove interceptor
interceptors.eject(interceptor)

// create a new isolated `fetchApi` with its own `interceptors`
const { fetchApi, interceptors } = createFetchApi()

Sponsors

1stG RxTS UnTS
1stG Open Collective backers and sponsors RxTS Open Collective backers and sponsors UnTS Open Collective backers and sponsors

Backers

Backers

1stG RxTS UnTS
1stG Open Collective backers and sponsors RxTS Open Collective backers and sponsors UnTS Open Collective backers and sponsors

Changelog

Detailed changes for each release are documented in CHANGELOG.md.

License

MIT © JounQin@1stG.me

x-fetch's People

Contributors

github-actions[bot] avatar jounqin avatar

Stargazers

 avatar  avatar  avatar

x-fetch's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Using npm packages for Renovate presets is now deprecated. Please migrate to repository-based presets instead.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): update dependency @changesets/cli to ^2.27.7
  • chore(deps): update dependency @mdx-js/rollup to ^3.0.1
  • chore(deps): update dependency @types/mdx to ^2.0.13
  • chore(deps): update dependency @types/web to ^0.0.155
  • chore(deps): update dependency lint-staged to ^15.2.9
  • fix(deps): update dependency tslib to ^2.6.3
  • chore(deps): update dependency @commitlint/cli to ^18.6.1
  • chore(deps): update dependency @edge-runtime/vm to ^3.2.0
  • chore(deps): update dependency @size-limit/preset-small-lib to ^11.1.4
  • chore(deps): update dependency @vitejs/plugin-react-swc to ^3.7.0
  • chore(deps): update dependency eslint to ^8.57.0
  • chore(deps): update dependency github-markdown-css to ^5.6.1
  • chore(deps): update dependency prettier to ^3.3.3
  • chore(deps): update dependency react-router-dom to ^6.26.1
  • chore(deps): update dependency simple-git-hooks to ^2.11.1
  • chore(deps): update dependency size-limit to ^11.1.4
  • chore(deps): update dependency stylelint to ^16.8.2
  • chore(deps): update dependency type-coverage to ^2.29.1
  • chore(deps): update dependency typescript to ^5.5.4
  • chore(deps): update dependency unplugin-auto-import to ^0.18.2
  • chore(deps): update dependency vite to ^5.4.1
  • chore(deps): update node.js to >=14.21.3
  • chore(deps): update react monorepo (@types/react, @types/react-dom, react, react-dom)
  • chore(deps): update vitest monorepo to ^1.6.0 (@vitest/coverage-istanbul, vitest)
  • chore(deps): update yarn to v4.4.0
  • chore(deps): update codecov/codecov-action action to v4
  • chore(deps): update dependency @commitlint/cli to v19
  • chore(deps): update dependency @edge-runtime/vm to v4
  • chore(deps): update dependency @pkgr/rollup to v6
  • chore(deps): update dependency eslint to v9
  • chore(deps): update github/codeql-action action to v3
  • chore(deps): update node.js to v20 (node, @types/node)
  • chore(deps): update vitest monorepo to v2 (major) (@vitest/coverage-istanbul, vitest)

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v4
  • actions/setup-node v4
  • codecov/codecov-action v3
.github/workflows/codeql.yml
  • actions/checkout v4
  • github/codeql-action v2
  • github/codeql-action v2
  • github/codeql-action v2
.github/workflows/release.yml
  • actions/checkout v4
  • actions/setup-node v4
.github/workflows/size-limit.yml
  • actions/checkout v4
  • actions/setup-node v4
  • andresz1/size-limit-action v1
.github/workflows/vercel.yml
  • actions/checkout v4
  • amondnet/vercel-action v25
npm
package.json
  • tslib ^2.6.2
  • @1stg/app-config ^10.0.1
  • @1stg/lib-config ^13.0.0
  • @changesets/changelog-github ^0.5.0
  • @changesets/cli ^2.27.1
  • @commitlint/cli ^18.4.4
  • @edge-runtime/vm ^3.1.7
  • @mdx-js/rollup ^3.0.0
  • @pkgr/rollup ^5.0.0
  • @size-limit/preset-small-lib ^11.0.2
  • @types/mdx ^2.0.10
  • @types/node ^20.11.5
  • @types/react ^18.2.48
  • @types/react-dom ^18.2.18
  • @types/web ^0.0.135
  • @vitejs/plugin-react-swc ^3.5.0
  • @vitest/coverage-istanbul ^1.2.1
  • concurrently ^8.2.2
  • eslint ^8.56.0
  • github-markdown-css ^5.5.0
  • lint-staged ^15.2.0
  • prettier ^3.2.4
  • react ^18.2.0
  • react-dom ^18.2.0
  • react-router-dom ^6.21.2
  • rehype-slug ^6.0.0
  • remark-gfm ^4.0.0
  • simple-git-hooks ^2.9.0
  • size-limit ^11.0.2
  • stylelint ^16.1.0
  • type-coverage ^2.27.1
  • typescript ^5.3.3
  • unplugin-auto-import ^0.17.3
  • vite ^5.0.11
  • vitest ^1.2.1
  • node >=14.0.0
  • prettier ^3.2.4
  • yarn 4.0.2
nvm
.nvmrc

  • Check this box to trigger a request for Renovate to run again on this repository

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.