score:1

Accepted answer

Why does axios post method stop working after 6 consecutive post calls?

It is probably because your original code was not sending any response back to the client. A browser has limits on how many requests it will allow in progress to the same host. Once it hits that limit, it queues the request and waits until one of the previous requests finishes before sending the queued request.

So, once you added res.send(...) to your POST handler (for both success and error conditions), then the browser didn't hit its simultaneous requests limit to the same host and you could send more requests just fine.

score:1

I am an idiot. For some reason I had left the try and catch block out of the post method in the router. That is why it wasn't giving any response from the router!

I have no idea why the database updates 6 times successfully without a try/catch block. But adding in the try catch and response allows it to update endlessly.

(see updated router post method with try and catch below)

router.post('/pageupdate/:_id',auth, async(req,res)=>{
console.log("received request to update: ",req.body," id ",req.params);
const filter = { "_id": req.params };
const update = [{ $set: req.body }];
try{
    let updatedDoc = await Pages.findOneAndUpdate(filter, update, {returnNewDocument: true});
    res.status(201).send(updatedDoc)
}
catch(e){
    console.log(e);
    res.status(400).send(e)
}

});


Related Query

More Query from same tag