I
I
Ilya2018-11-20 13:36:47
JavaScript
Ilya, 2018-11-20 13:36:47

How to go back with saving form data on koa?

There is a router

projectRouter.post("/add",  async ctx => {
    try {
        await Projects.add(ctx.request.body,ctx.state.user.id);
        ctx.redirect('/user/projects/');
    } catch (e) {
        ctx.redirect('back');
    }
});

On error, it returns back to the page with the form, the form data is deleted, but if you press the back button in the browser (next to the url input line), then we go back and the form data is saved.
Or is it impossible to implement such a return on the backend side, without saving the data and substituting it into the template?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question