0
有什麼方法將數據從POST函數中的請求轉移到GET函數的資源?在Node.js中驗證錯誤後重定向POST數據
app.get '/form', routes.getForm
app.post '/form', routes.postForm
app.get '/form', routes.getForm # pass return data from previous POST call
我需要驗證一些表單數據並且想要預設在POST之前輸入的數據。
但你怎麼能堅持表單數據用戶輸入以前的錯誤valdiation並顯示給用戶何時渲染錯誤?當res.redirect被執行時,attributes.body得到重置。 – p1nox
您可以將其存儲在會話中,然後在表單頁面呈現後每次刪除它。這是https://github.com/jaredhanson/connect-flash如何工作。 – alessioalex
是的,我已經實施了這種方法,謝謝! – p1nox