Fetch within a Fetch Issue
Just starting out with Javascript and ran into a problem when trying to execute a fetch within a fetch. Looking for a way to execute code once the first fetch completes. Using ‘then’ doesn’t seem to work as the call below to AjaxFileLoadInit() invokes a second fetch and locks things up. If I call AjaxFileLoadInit() later on after the first fetch has finished by way of a link everything works.
fetch(FileName)
.then(res => res.text())
.then(txt => Element.innerHTML = txt)
.then(txt => AjaxFileLoadJavaFix(Element))
.then(txt => AjaxFileLoadInit());
Thanks.
Re: Fetch within a Fetch Issue
I apologize because my answer comes several months late, but looking at your code it should be executing asynchronously. Assuming that AjaxFileLoadJavaFix and AjaxFileLoadInit both return promises, your code should behave as expected.
My guess is that the two methods don't actually return a promise, but could you provide us with those methods?