Skip to content

Commit

Permalink
Merge branch 'main' into pr/tmkx/256
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 16, 2023
2 parents 6e5a5cd + f5d94fa commit 9d2258f
Show file tree
Hide file tree
Showing 8 changed files with 1,493 additions and 1,204 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: autofix.ci # needed to securely identify the workflow

on:
pull_request:
push:
branches: ["main"]

permissions:
contents: read

jobs:
autofix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
- run: pnpm install
- name: Fix lint issues
run: pnpm run lint:fix
- uses: autofix-ci/action@8caa572fd27b0019a65e4c695447089c8d3138b9
with:
commit-message: "chore: apply automated fixes"
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"trailingComma": "es5"
}
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,29 @@ await ofetch('/url', { ignoreResponseError: true })

## ✔️ Auto Retry

`ofetch` Automatically retries the request if an error happens. Default is `1` (except for `POST`, `PUT`, `PATCH` and `DELETE` methods that is `0`)
`ofetch` Automatically retries the request if an error happens and if response status code is included in `retryStatusCodes` list:

**Retry status codes:**

- `408` - Request Timeout
- `409` - Conflict
- `425` - Too Early
- `429` - Too Many Requests
- `500` - Internal Server Error
- `502` - Bad Gateway
- `503` - Service Unavailable
- `504` - Gateway Timeout

You can specifcy amount of retires and delay between them using `retry` and `retryDelay` options.

Default for `retry` is `1` retry, except for `POST`, `PUT`, `PATCH` and `DELETE` methods ofetch does not retry.

Default for `retryDelay` is zero ms.

```ts
await ofetch('http://google.com/404', {
retry: 3
retry: 3,
retryDelay: 500 // ms
})
```

Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,25 @@
"test": "pnpm lint && vitest run --coverage"
},
"dependencies": {
"destr": "^2.0.0",
"destr": "^2.0.1",
"node-fetch-native": "^1.2.0",
"ufo": "^1.1.2"
"ufo": "^1.2.0"
},
"devDependencies": {
"@types/node": "^20.3.1",
"@vitest/coverage-v8": "^0.32.2",
"changelogen": "^0.5.3",
"eslint": "^8.43.0",
"@types/node": "^20.5.0",
"@vitest/coverage-v8": "^0.34.1",
"changelogen": "^0.5.4",
"eslint": "^8.47.0",
"eslint-config-unjs": "^0.2.1",
"fetch-blob": "^4.0.0",
"formdata-polyfill": "^4.0.10",
"h3": "^1.6.6",
"jiti": "^1.18.2",
"listhen": "^1.0.4",
"prettier": "^2.8.8",
"typescript": "^5.1.3",
"unbuild": "2.0.0-rc.0",
"vitest": "^0.32.2"
"h3": "^1.8.0",
"jiti": "^1.19.1",
"listhen": "^1.3.0",
"prettier": "^3.0.2",
"typescript": "^5.1.6",
"unbuild": "^1.2.1",
"vitest": "^0.34.1"
},
"packageManager": "[email protected].2"
}
"packageManager": "[email protected].12"
}
Loading

0 comments on commit 9d2258f

Please sign in to comment.