RESOLVED FIXED170985
Failed to fetch with undefined headers
https://bugs.webkit.org/show_bug.cgi?id=170985
Summary Failed to fetch with undefined headers
Cheng You Bai (:cybai)
Reported 2017-04-19 02:38:28 PDT
When I tried to use `fetch` with `undefined` headers, the promise will be rejected with `TypeError: undefined is not an object`. Ex. `fetch('/my-awesome-api', { headers: undefined })` ``` TypeError: undefined is not an object anonymous fillFetchHeaders initializeFetchRequest [native code] fetch tryCatch invoke step (anonymous function) run (anonymous function) flush ``` I'm using OSX 10.11 El Capitan and on Safari 10.1 (11603.1.30.0.34). I know there's another [bugzilla issue](https://bugs.webkit.org/show_bug.cgi?id=168043) about this issue. However, I still face this issue. If the fix is released yet, please kindly help me to close this issue. Thanks.
Attachments
youenn fablet
Comment 1 2017-04-20 08:19:13 PDT
The next Safari release will probably include it. In the meantime, could you use a workaround like not setting the "headers" key when its value would be undefined?
Cheng You Bai (:cybai)
Comment 2 2017-04-20 18:51:38 PDT
Hi youenn fablet, Yes, I've tried to use empty object to handle this issue and it works fine. Ex. ``` fetch('/my-awesome-api', { headers: headers || {} }); ``` Hope it will be released soon, thanks!
youenn fablet
Comment 3 2017-04-20 20:47:31 PDT
Closing bug as fixed. Please reopen if needed.
Note You need to log in before you can comment on or make changes to this bug.