javascript - Express.JS Handling Server-Side Errors -


I am setting up routes for an application and do my best to maintain a permanent architecture. I am here.

Facing some type of error (not necessarily a validation error), the process of accepting the form input and then showing the user is the same form, but they are the server at the first place Including data sent to?

At first, I had stored the post data in one session, but never felt like it was a good solution, and like hacks.

Then I adjusted my routes, and instead to submit the form, app.post | Put | Using the del () , then using the one path along with the app, all () will be used as "catch-all", if I have a If I have to face the error, then I'll call the next () , the handle on my "catch-all" route has to be ended because it wandered me from my original macro perspective.

Now, I have set my path to mirror more accurately a precise approach. However, if I use the app.redirect () , the data is lost in the redirect. I feel like another hack is finished using: controller.new_form.apply (this, logic); (It is called in Controller.) )

Of course, I can use client-side legalization, but I want to create an app I am doing my best, which works completely server-side, then adding the client-side code as a way to improve the user experience where it is supported.

Is there some method available for express.js (or connect.js), which accepts form actions on the different URI from the form, but actually allows the browser to go back without redirecting Can the form remain for my users (as well as show an error message)?

You may res.render Can you call? So if all the posted form data is confirmed, go to res.render 'thankyou.jade' otherwise res.render 'form.jade' again Do you? It is similar to the suggestions of Casey Binner, without defining specific methods for each, although this is a good thing if you have any special reasoning.

Comments