File tree 1 file changed +11
-16
lines changed 1 file changed +11
-16
lines changed Original file line number Diff line number Diff line change @@ -95,32 +95,27 @@ class Fetch extends EE {
95
95
}
96
96
97
97
// https://fetch.spec.whatwg.org/#fetch-method
98
- async function fetch ( ... args ) {
99
- if ( args . length < 1 ) {
98
+ async function fetch ( input , init = undefined ) {
99
+ if ( arguments . length < 1 ) {
100
100
throw new TypeError (
101
- `Failed to execute 'fetch' on 'Window': 1 argument required, but only ${ args . length } present.`
102
- )
103
- }
104
- if (
105
- args . length >= 1 &&
106
- typeof args [ 1 ] !== 'object' &&
107
- args [ 1 ] !== undefined
108
- ) {
109
- throw new TypeError (
110
- "Failed to execute 'fetch' on 'Window': cannot convert to dictionary."
101
+ `Failed to execute 'fetch' on 'Window': 1 argument required, but only ${ arguments . length } present.`
111
102
)
112
103
}
113
104
114
- const resource = args [ 0 ]
115
- const init = args . length >= 1 ? args [ 1 ] ?? { } : { }
116
-
117
105
// 1. Let p be a new promise.
118
106
const p = createDeferredPromise ( )
119
107
120
108
// 2. Let requestObject be the result of invoking the initial value of
121
109
// Request as constructor with input and init as arguments. If this throws
122
110
// an exception, reject p with it and return p.
123
- const requestObject = new Request ( resource , init )
111
+ let requestObject
112
+
113
+ try {
114
+ requestObject = new Request ( input , init )
115
+ } catch ( e ) {
116
+ p . reject ( e )
117
+ return p . promise
118
+ }
124
119
125
120
// 3. Let request be requestObject’s request.
126
121
const request = requestObject [ kState ]
You can’t perform that action at this time.
0 commit comments