Assume that I have a form as such that is submitted to a POST route /example
:
<form action="/example" method="POST">
<input type="text" name="fname"><br>
<input type="text" name="lname"><br>
<button type="submit">Send</button>
</form>
app.js:
app.post('/example', (req, res) => {
...
});
server.js
const app = require('./app');
app.listen(3000, () => {
console.log('server is running on port 3000');
});
Does Javascript provide a way to prevent the form submission if the server disconnects in order to prevent the website from crashing?
I have searched online but couldn't find any such solutions to this problem.