I
I
i_surin2016-06-10 19:53:48
Node.js
i_surin, 2016-06-10 19:53:48

Why doesn't redirect work after POST request in Node.js?

I honestly searched, I didn’t find anything, I’m racking my brain, I can’t understand what’s the matter, the
form in the html file refers to the handler

app.post('/complete', function(req, res) {
  completeFile = "]}";

  fs.appendFile(projectName + '.json', completeFile, function(err) {
    if (err) console.error(err);
    console.log('file completed');
    res.writeHead(301, {
      Location: "result.html"
    });
    res.end()
  });
})

in theory, res.writeHead should transfer to the result.html page, which is in the same folder as the server.js file (with node code) and with the index.html file on which the form is
. How to make it work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
#
#algooptimize #bottize, 2016-06-10
@i_surin

an asynchronous call or what? It won't work (probably)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question