Can I use JavaScript fetch() to insert an inline svg in the DOM?
You can. I think the following should work:
fetch('bar.svg')
.then(r => r.text())
.then(text => {
el.innerHTML = text;
})
.catch(console.error.bind(console));
The second then
is for resolving the .text()
, which "takes a Response stream and reads it to completion" (MDN) (MDN Eng).