File tree 9 files changed +328
-1235
lines changed
9 files changed +328
-1235
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ await ofetch("https://google.com/404");
99
99
To catch error response:
100
100
101
101
``` ts
102
- await ofetch (" /url" ).catch ((err ) => err .data );
102
+ await ofetch (" /url" ).catch ((error ) => error .data );
103
103
```
104
104
105
105
To bypass status error catching you can set ` ignoreResponseError ` option:
Original file line number Diff line number Diff line change
1
+ import unjs from "eslint-config-unjs" ;
2
+
3
+ // https://github.com/unjs/eslint-config
4
+ export default unjs ( {
5
+ ignores : [ ] ,
6
+ rules : {
7
+ "no-undef" : 0 ,
8
+ "unicorn/consistent-destructuring" : 0 ,
9
+ "unicorn/no-await-expression-member" : 0
10
+ } ,
11
+ } ) ;
Original file line number Diff line number Diff line change 62
62
"scripts" : {
63
63
"build" : " unbuild" ,
64
64
"dev" : " vitest" ,
65
- "lint" : " eslint --ext .ts . && prettier -c src test playground examples" ,
66
- "lint:fix" : " eslint --fix --ext .ts . && prettier -w src test playground examples" ,
65
+ "lint" : " eslint . && prettier -c src test playground examples" ,
66
+ "lint:fix" : " eslint --fix . && prettier -w src test playground examples" ,
67
67
"prepack" : " pnpm build" ,
68
68
"play" : " jiti playground/index.ts" ,
69
69
"release" : " pnpm test && changelogen --release && npm publish && git push --follow-tags" ,
78
78
"@types/node" : " ^20.12.12" ,
79
79
"@vitest/coverage-v8" : " ^1.6.0" ,
80
80
"changelogen" : " ^0.5.5" ,
81
- "eslint" : " ^8.57 .0" ,
82
- "eslint-config-unjs" : " ^0.2 .1" ,
81
+ "eslint" : " ^9.2 .0" ,
82
+ "eslint-config-unjs" : " ^0.3 .1" ,
83
83
"fetch-blob" : " ^4.0.0" ,
84
84
"formdata-polyfill" : " ^4.0.10" ,
85
85
"h3" : " ^1.11.1" ,
92
92
"vitest" : " ^1.6.0"
93
93
},
94
94
"packageManager" : " pnpm@9.1.1"
95
- }
95
+ }
Original file line number Diff line number Diff line change @@ -4,13 +4,12 @@ async function main() {
4
4
// const r = await $fetch<string>('http://google.com/404')
5
5
const r = await $fetch < string > ( "http://httpstat.us/500" ) ;
6
6
// const r = await $fetch<string>('http://httpstat/500')
7
- // eslint-disable-next-line no-console
7
+
8
8
console . log ( r ) ;
9
9
}
10
10
11
11
// eslint-disable-next-line unicorn/prefer-top-level-await
12
12
main ( ) . catch ( ( error ) => {
13
- // eslint-disable-next-line no-console
14
13
console . error ( error ) ;
15
14
// eslint-disable-next-line unicorn/no-process-exit
16
15
process . exit ( 1 ) ;
Original file line number Diff line number Diff line change 1
1
import type { FetchContext , IFetchError } from "./types" ;
2
2
3
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
3
4
export class FetchError < T = any > extends Error implements IFetchError < T > {
4
5
constructor ( message : string , opts ?: { cause : unknown } ) {
5
6
// @ts -ignore https://v8.dev/features/error-cause
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export interface $Fetch {
21
21
22
22
export interface FetchContext < T = any , R extends ResponseType = ResponseType > {
23
23
request : FetchRequest ;
24
- // eslint-disable-next-line no-use-before-define
24
+
25
25
options : FetchOptions < R > ;
26
26
response ?: FetchResponse < T > ;
27
27
error ?: Error ;
@@ -70,7 +70,6 @@ export interface FetchOptions<R extends ResponseType = ResponseType>
70
70
}
71
71
72
72
export interface CreateFetchOptions {
73
- // eslint-disable-next-line no-use-before-define
74
73
defaults ?: FetchOptions ;
75
74
fetch ?: Fetch ;
76
75
Headers ?: typeof Headers ;
You can’t perform that action at this time.
0 commit comments