How to end an express.js / node POST response?

前端 未结 7 1652
情歌与酒
情歌与酒 2020-12-28 12:51

Im trying to just stop the post request after I\'ve saved a document to the DB, ie:

app.post(\'/blah\'), function(req,res){ 
//my code does a bunch of stuff
         


        
7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-28 13:24

    The best way to end the express routing without routing to new page or what ever the mess express want you not to stay on the current page although you have your own reason is to use window.stop, for example a form, you use javascript to handle the submission, the timeout should be enough to ensure the data is send as POST method.

    document.myform.mysubmit.click()
        setTimeout(function(){ 
            window.stop() 
        }, 3000);
    

提交回复
热议问题