0

i have multiple devices which i want to fire a command over a api But using fetch is not working as expected. As you can see in the picture, 9 requests takes about a minute to finish, because the execution takes about 6 seconds per request. If i fire the command, they all appear in the dev console, but "pending" Why this is not working?

enter image description here

enter image description here

async function getExecuteOutput(devices, formData) {

    $.each(devices, async function( index, value ) {
        fetch(
            '/api/execute.php',
            {
                method: 'POST',
                body: foormData
            }
        ).then((resp) => resp.json()).then(response => {
            console.log(response);
        });
    });
}
1
  • 2
    Seems like your php code can't handle parallel responses for some reason.u Commented Jul 3, 2022 at 13:47

1 Answer 1

2

The screenshot shows they are running in parallel. You can see the green bars in the screenshot starting at the same point. (Up to a point anyway: browsers limit the number of HTTP requests they can have in flight to the same server).

Your server-side code's inability to handle that (probably due to database locking) has nothing to do with fetch.

Sign up to request clarification or add additional context in comments.

1 Comment

FYI: Its the maybe session locking in php, for everyone who have the same problem :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.