Socket
Socket
Sign inDemoInstall

ofetch

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ofetch - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

dist/error-d5becc6e.d.ts

4

dist/index.d.ts

@@ -1,3 +0,3 @@

import { $ as $Fetch } from './error-04138797.js';
export { C as CreateFetchOptions, b as FetchContext, e as FetchError, c as FetchOptions, F as FetchRequest, a as FetchResponse, S as SearchParameters, d as createFetch, f as createFetchError } from './error-04138797.js';
import { $ as $Fetch } from './error-d5becc6e.js';
export { C as CreateFetchOptions, b as FetchContext, e as FetchError, c as FetchOptions, F as FetchRequest, a as FetchResponse, S as SearchParameters, d as createFetch, f as createFetchError } from './error-d5becc6e.js';

@@ -4,0 +4,0 @@ declare const fetch: typeof globalThis.fetch;

@@ -1,3 +0,3 @@

import { $ as $Fetch } from './error-04138797.js';
export { C as CreateFetchOptions, b as FetchContext, e as FetchError, c as FetchOptions, F as FetchRequest, a as FetchResponse, S as SearchParameters, d as createFetch, f as createFetchError } from './error-04138797.js';
import { $ as $Fetch } from './error-d5becc6e.js';
export { C as CreateFetchOptions, b as FetchContext, e as FetchError, c as FetchOptions, F as FetchRequest, a as FetchResponse, S as SearchParameters, d as createFetch, f as createFetchError } from './error-d5becc6e.js';

@@ -4,0 +4,0 @@ declare function createNodeFetch(): (input: RequestInfo, init?: RequestInit) => any;

{
"name": "ofetch",
"version": "1.0.1",
"version": "1.1.0",
"description": "A better fetch API. Works on node, browser and workers.",

@@ -10,3 +10,15 @@ "repository": "unjs/ofetch",

"exports": {
"./package.json": "./package.json",
".": {
"browser": "./dist/index.mjs",
"bun": "./dist/index.mjs",
"deno": "./dist/index.mjs",
"edge-light": "./dist/index.mjs",
"edge-routine": "./dist/index.mjs",
"lagon": "./dist/index.mjs",
"netlify": "./dist/index.mjs",
"react-native": "./dist/index.mjs",
"wintercg": "./dist/index.mjs",
"worker": "./dist/index.mjs",
"workerd": "./dist/index.mjs",
"node": {

@@ -48,22 +60,22 @@ "types": "./dist/node.d.ts",

"destr": "^1.2.2",
"node-fetch-native": "^1.0.2",
"ufo": "^1.1.0"
"node-fetch-native": "^1.2.0",
"ufo": "^1.1.2"
},
"devDependencies": {
"@types/node": "^18.13.0",
"@vitest/coverage-c8": "^0.28.5",
"changelogen": "^0.4.1",
"eslint": "^8.34.0",
"eslint-config-unjs": "^0.1.0",
"fetch-blob": "^3.2.0",
"@types/node": "^20.2.5",
"@vitest/coverage-v8": "^0.32.0",
"changelogen": "^0.5.3",
"eslint": "^8.42.0",
"eslint-config-unjs": "^0.2.1",
"fetch-blob": "^4.0.0",
"formdata-polyfill": "^4.0.10",
"h3": "^1.4.0",
"jiti": "^1.17.0",
"listhen": "^1.0.2",
"prettier": "^2.8.4",
"typescript": "^4.9.5",
"unbuild": "^1.1.1",
"vitest": "^0.28.5"
"h3": "^1.6.6",
"jiti": "^1.18.2",
"listhen": "^1.0.4",
"prettier": "^2.8.8",
"typescript": "^5.1.3",
"unbuild": "^1.2.1",
"vitest": "^0.32.0"
},
"packageManager": "pnpm@7.27.0"
}
"packageManager": "pnpm@8.6.1"
}

@@ -5,6 +5,8 @@ # ofetch

[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![Codecov][codecov-src]][codecov-href]
[![bundle][bundle-src]][bundle-href]
[![License][license-src]][license-href]
[![JSDocs][jsdocs-src]][jsdocs-href]
> A better fetch API. Works on node, browser and workers.
A better fetch API. Works on node, browser and workers.

@@ -33,7 +35,2 @@ ## 🚀 Quick Start

<details>
<summary>Spoiler</summary>
<img src="https://media.giphy.com/media/Dn1QRA9hqMcoMz9zVZ/giphy.gif">
</details>
## ✔️ Works with Node.js

@@ -93,11 +90,17 @@

In order to bypass errors as response you can use `error.data`:
To catch error response:
```ts
await ofetch(...).catch((error) => error.data)
await ofetch('/url').catch(err => err.data)
```
To bypass status error catching you can set `ignoreResponseError` option:
```ts
await ofetch('/url', { ignoreResponseError: true })
```
## ✔️ Auto Retry
`ofetch` Automatically retries the request if an error happens. Default is `1` (except for `POST`, `PUT` and `PATCH` methods that is `0`)
`ofetch` Automatically retries the request if an error happens. Default is `1` (except for `POST`, `PUT`, `PATCH` and `DELETE` methods that is `0`)

@@ -242,3 +245,3 @@ ```ts

// response.data
// response._data
// response.headers

@@ -286,15 +289,13 @@ // ...

<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/ofetch?style=flat-square
[npm-version-src]: https://img.shields.io/npm/v/ofetch?style=flat&colorA=18181B&colorB=F0DB4F
[npm-version-href]: https://npmjs.com/package/ofetch
[npm-downloads-src]: https://img.shields.io/npm/dm/ofetch?style=flat-square
[npm-downloads-src]: https://img.shields.io/npm/dm/ofetch?style=flat&colorA=18181B&colorB=F0DB4F
[npm-downloads-href]: https://npmjs.com/package/ofetch
[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/ofetch/ci/main?style=flat-square
[github-actions-href]: https://github.com/unjs/ofetch/actions?query=workflow%3Aci
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/ofetch/main?style=flat-square
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/ofetch/main?style=flat&colorA=18181B&colorB=F0DB4F
[codecov-href]: https://codecov.io/gh/unjs/ofetch
[bundle-src]: https://img.shields.io/bundlephobia/minzip/ofetch?style=flat-square
[bundle-src]: https://img.shields.io/bundlephobia/minzip/ofetch?style=flat&colorA=18181B&colorB=F0DB4F
[bundle-href]: https://bundlephobia.com/result?p=ofetch
[license-src]: https://img.shields.io/github/license/unjs/ofetch.svg?style=flat&colorA=18181B&colorB=F0DB4F
[license-href]: https://github.com/unjs/ofetch/blob/main/LICENSE
[jsdocs-src]: https://img.shields.io/badge/jsDocs.io-reference-18181B?style=flat&colorA=18181B&colorB=F0DB4F
[jsdocs-href]: https://www.jsdocs.io/package/ofetch

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc