Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  8] [ 5]  / answers: 1 / hits: 20368  / 8 Years ago, sun, march 6, 2016, 12:00:00

For some reason fetch (https://fetch.spec.whatwg.org/) is not defined in Safari (Version 9.0.3), does anyone know why? It seems to be the standard and works fine in Chrome and Firefox. Can't seem to find anyone else having the same issue



I am using react with redux and here is some example code:



export function fetchData (url) {
return dispatch => {
dispatch(loading())
fetch(url, {
method: 'GET'
})
.then(response => {
response.json()
.then(data => {
dispatch(success(data))
})
})
}
}

More From » safari

 Answers
74

You can use https://github.com/github/fetch polyfill for unsupported browsers.



npm install whatwg-fetch --save; 


Edit: (per the comments)



add



import 'whatwg-fetch'; 


in each file before using fetch – oliviergg


[#63032] Thursday, March 3, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
siena

Total Points: 199
Total Questions: 91
Total Answers: 91

Location: Pitcairn Islands
Member since Fri, Oct 15, 2021
3 Years ago
;