This may have been asked before but I can't seem to find a solution, so apologies if this is the case.
I have a simple node app in development which uses express. One of the post routes returns a http 204 and sends it, below is my code:
router.post("/:id", function(req, res, next) {
if (!req.session.userId) {
res.status(204).send();
} else {
console.log(req.params.id);
User.findById(req.session.userId, function (err, user) {
if (err) return handleError(err);
const nameForDatabase = req.params.id + "Correct";
console.log(nameForDatabase);
user.set({[nameForDatabase]: req.body.correct});
user.save(function (err, updatedUser) {
if (err) return handleError(err);
console.log(updatedUser);
});
});
res.status(204).send();
}
});
In desktop chrome this behaves as expected, with the post updating user data, and the page otherwise remaining the same. In iOS, a blank page is loaded.
Is there a way to stop a blank page from appearing on iPhones/iPads?
Many thanks in advance.
NB: https://simplenotesapp.herokuapp.com/fluids is a mock up of what I'm going for, it's important that the 204 doesn't load a new page, as you'll see that once the user has answered questions and submitted them at the bottom, the correct answers appear.