我想在重定向用户后写入DB:
exports.contentServer = functions.https.onRequest((request, response) => {
...
...
return response.redirect(finalUrl + "front?action=" + action )
.then(function(){ // **** error : .then of undefined
....
我得到了一个错误的承诺。
Cannot read property 'then' of undefined
at exports.contentServer.functions.https.onRequest
据我所知,redirection
不返回promise
。 实际上,从错误消息中的undefined
来看,它似乎根本没有返回任何内容。 文档也没有显示任何返回值:https://expressjs.com/en/api.html#res.redirect
如果它要返回一些东西,您可以捕获该值并在以后返回它:
const result = response.redirect(finalUrl + "front?action=" + action )
....
return result;