Bug 170985
| Summary: | Failed to fetch with undefined headers | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Cheng You Bai (:cybai) <cyb.ai.815> |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | achristensen, cyb.ai.815, youennf |
| Priority: | P2 | ||
| Version: | Safari 10 | ||
| Hardware: | Mac | ||
| OS: | OS X 10.11 | ||
Cheng You Bai (:cybai)
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
youenn fablet
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)
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
Closing bug as fixed. Please reopen if needed.