fetch not defined in Safari (ReferenceError: Can't find variable: fetch)

前端 未结 2 1972
无人及你
无人及你 2021-02-01 05:03

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

2条回答
  •  春和景丽
    2021-02-01 05:39

    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

提交回复
热议问题