Fetch JSON exists, but consider adding fetching XML (for those poor souls that don't have access to JSON). Here's a code snippet:
fetch('http://xml-coreutils.sourceforge.net/food.xml')
.then(response => response.text())
.then(data => {
// console.log(data); // The raw string
let parser = new DOMParser();
let xml = parser.parseFromString(data, 'application/xml');
console.log(xml);
})
.catch(console.error);
Here's a YouTube video of Steve Griffith working with JS to fetch XML.
Love Code To Go by the way! Thanks for all you do.
Fetch JSON exists, but consider adding fetching XML (for those poor souls that don't have access to JSON). Here's a code snippet:
Here's a YouTube video of Steve Griffith working with JS to fetch XML.
Love Code To Go by the way! Thanks for all you do.