Release - Latest | Release - Pre | |
---|---|---|
() | () | |
A NodeJS module to extend fetch
.
This project is inspired from:
- Deno - Standard Library - Async
- axios (GitHub)(NPM)
- jhermsmeier/node-http-link-header (GitHub)(NPM)
- node-fetch (GitHub)(NPM)
- octokit/plugin-paginate-rest.js (GitHub)(NPM)
- octokit/plugin-retry.js (GitHub)(NPM)
- sindresorhus/got (GitHub)(NPM)
- sindresorhus/ky (GitHub)(NPM)
- superagent (GitHub)(NPM)
- thlorenz/parse-link-header (GitHub)(NPM)
- Automatically retry on failure requests, preferentially obey the response header
Retry-After
. - Redirect fine control.
- Simplify URL paginate requests.
- Target Version: >= v18.12.0, &:
- TypeScript >= v5.1.0 [Development]
- Require Permission: N/A
- Registry:
- NPM
npm install @hugoalh/exfetch[@<Tag>]
import ... from "@hugoalh/exfetch";
- NPM
ℹ️ Notice: It is also able to import part of the module with sub path if available, see file
package.json
propertyexports
for available sub paths.
ℹ️ Notice: Documentation is included inside the script file.
ExFetch
HTTPHeaderLink
HTTPHeaderRetryAfter
exFetch
exFetchPaginate
-
import { exFetchPaginate } from "@hugoalh/exfetch/exfetch"; const responses: Response[] = await exFetchPaginate("https://api.github.com/repos/microsoft/vscode/labels?per_page=100"); responses.map((response: Response) => { return response.ok; }).includes(false); //=> false (`false` when no broken page, otherwise `true`) const result = []; for (const response of responses) { result.push(...(await response.json())); } result; /*=> [ { "id": 2339554941, "node_id": "MDU6TGFiZWwyMzM5NTU0OTQx", "url": "https://api.github.com/repos/microsoft/vscode/labels/:apple:%20si", "name": ":apple: si", "color": "e99695", "default": false, "description": "Issues related to apple silicon" }, { "id": 421131022, "node_id": "MDU6TGFiZWw0MjExMzEwMjI=", "url": "https://api.github.com/repos/microsoft/vscode/labels/*as-designed", "name": "*as-designed", "color": "E2A1C2", "default": false, "description": "Described behavior is as designed" }, { "id": 409283388, "node_id": "MDU6TGFiZWw0MDkyODMzODg=", "url": "https://api.github.com/repos/microsoft/vscode/labels/*caused-by-extension", "name": "*caused-by-extension", "color": "E2A1C2", "default": false, "description": "Issue identified to be caused by an extension" }, { "id": 766755777, "node_id": "MDU6TGFiZWw3NjY3NTU3Nzc=", "url": "https://api.github.com/repos/microsoft/vscode/labels/*dev-question", "name": "*dev-question", "color": "E2A1C2", "default": false, "description": "VS Code Extension Development Question" }, { "id": 366106217, "node_id": "MDU6TGFiZWwzNjYxMDYyMTc=", "url": "https://api.github.com/repos/microsoft/vscode/labels/*duplicate", "name": "*duplicate", "color": "E2A1C2", "default": false, "description": "Issue identified as a duplicate of another issue(s)" }, ... +467 ] */