Multiple request using useMutation
Hi everyone,
Let's say I have a todo list (an array of objects), and I want to send a POST request to a specific endpoint to create a new todo. The endpoint accepts an object, not an array.
Currently, what I do is loop through each todo and call the function like this:
todos.forEach(async (todo) => await createTodoHandler(todo));
How can I refactor this using useMutation, and what is the best way to handle multiple calls similar to the previous example?
1 Reply
flat-fuchsia•2y ago
Your mutation accepts the array and then does Promise.all of the requests?