I'd be interested to see if other people have similar go-to vanilla JS? If so, can you share a link here?
This one is mine:
https://github.com/donohoe/content/blob/master/posts/javascr...
(I follow basic ES6 syntax but easy to switch as needed)
This one is mine:
https://github.com/donohoe/content/blob/master/posts/javascr...
(I follow basic ES6 syntax but easy to switch as needed)
Edit: To clarify, a drop in replacement is what I was looking for.
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
fetch("http://www.example.com").then(res => res.json()).then(json => {})
Only big downside is no IE11 support but thankfully I don't have to worry about that so much these days. fetch(url, {
method: “POST”,
body: “a body”
})https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequ...
I don't know how far back it will help with old browsers. I'd need to test that and it will take awhile.
JSON.parse will throw a few older browsers by itself.