1.1: fetch() - Working With Data & APIs in JavaScript
Why Stack Overflow recommends it
Stack Overflow users link it when answerers want to give beginners a clear, friendly walkthrough of fetch() and Promises, often in place of older XMLHttpRequest code.
Recommended by 2 people across 2 different months, 2020 to 2021.
What it is
Daniel Shiffman of The Coding Train opens his Working With Data & APIs in JavaScript course with a client-side introduction to the fetch() API. He loads an image from a file, shows the Promise-based flow, and then rewrites it with async/await.
What people said
Recommends Schreyers · 2020-07 · Stack Overflow · on “IOS 13 XMLHttpRequest Blob audio/mpeg returns as text/html”
This was a miss leading issue, but for anyone stumbling upon it. The fix was to switch from using XMLHttpRequest to Fetch: [LINK] I had no clue about Fetch until I saw this video: [this video] and you will also need this: [LINK] to solve the CORS issue I also did removed the plugins: <plugin name="cordova-plugin-wkwebview-engine" source="npm" /> <plugin name="cordova-plugin-wkwebview-file-xhr" spec="~2.1.4" /> and adding this all-in-one plugin seemed to fix the issue. [LINK] Added these two preferences in the ios platform in config.xml <preference name="allowFileAccessFromFileURLs" value="true" /> <preference name="allowUniversalAccessFromFileURLs" value="true" />
Recommends Grzegorz Patyk · 2021-11 · Stack Overflow · on “How to render Jsonplaceholder data into HTML table?”
I would start with some HTTP overview [LINK] and learning about JS Fetch API [LINK] . After that, I really recomend this youtube video [this video] - very nicely explained. Good luck!
Cites Marcin Michno · 2020-04 · Stack Overflow · on “URL.createObjectURL which is not outdated”
Currently I'm trying to learn more about fetch, promises and overall API. I came across this video [this video] but he is using URL.createObjectURL() which didn't work for me and Google told me that this method is not supported by browsers anymore. So can someone explain to me how to rewrite this code to get correct results? Also do you have any recommendations where to learn more in this subject? <img src="" id="rainbow" /> <script> fetch('rainbow.png').then(response => { return response.blob(); }).then(blob => { console.log(blob); document.getElementById('rainbow').src = URL.createObjectURL(blob); }); </script>