2

here is my problem, when I post from using the classic form post the post goes to server if certain conditions are met the server then redirect to the specific page but when I use fetch request for posting due to the need to model data a certain way a yet with similar request the server doesn't redirect me to the wanted page and it just stays where it is , any solution my bet is I need to add something to my fetch so the fetch will respond to the redirection sent by the server.

// Front-End Code Fetch 
fetch('/pin', {
      credentials: "same-origin",
      mode: "same-origin",
      method: 'post',
      headers: {
        "Content-Type": "application/json"
      }, 
      body: JSON.stringify(inputJSON)
   })
// Back-End Code 
exports.pin = async (req, res, next) => {
        res.redirect(`/app`)
}

// Routing model
app.route('/pin')
    .post(authentication.pin) 
app.route('/app')
    .get(toAppControler.getApp)
Richardson
  • 1,804
  • 10
  • 38

1 Answers1

1

See this answer: you can't redirect a POST to a GET.
Can you add this to your code? This way you can either GET or POST /app?

app.route('/app').post(...)
Gpack
  • 1,878
  • 3
  • 18
  • 45