Home > Software design >  Using Express Js, I need submit button to redirect to another page
Using Express Js, I need submit button to redirect to another page

Time:12-12

I am creating a journal entry input text and once the user clicks "submit", the page should be redirected to show them their entry.

CodePudding user response:

Express.js has 2 parts of a request. The request and the response. The submit button should be part of a form that submits a request. You decide what to do with the request body in Express.js, and you send a response. You can send a status code, or, in your case, a redirect.

In your server-side post function, you'll want to make sure you include

res.redirect(307, 'url');

The 307 refers to the HTTP status code of "temporary redirect" and url refers to the new URL.

CodePudding user response:

You’re just going to have to make a get request from your front end on success of submission. All express will be doing in your case will be serving the requests. This is front end logic

  • Related