K
K
Konstantin Bozhkov2017-01-20 18:26:03
Node.js
Konstantin Bozhkov, 2017-01-20 18:26:03

How to remove post resubmission to node.js server?

.post((req, res) => {
  var data = req.body;
  news.create(data, function(err, news){
  if(err) throw(err);
    res.render('created-news', news);
  });
})

When the page is reloaded, the post is sent to the server again. PHP has header("Location: ".$_SERVER["HTTP_REFERER"]); How is this implemented in node.js?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2017-01-20
@bingo347

req.headers contains all the request headers parsed into an object, where the key is the header itself reduced to lower case, and the value is its value.
That is, in your case, you can check req.headers.referer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question