-
Dec 29th, 2024, 09:06 AM
#1
Thread Starter
Lively Member
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.
-
Jun 30th, 2025, 02:26 PM
#2
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|