admin管理员组文章数量:1023138
I have a url in the form www.a/users/uid, I want to get uid
.
Assume a function :
exports.smartlink = functions.https.onRequest((req, res) =>
Doing req.params
returns an empty array, whereas req.query.uid
when the url contains query strings works.
I have a url in the form www.a./users/uid, I want to get uid
.
Assume a function :
exports.smartlink = functions.https.onRequest((req, res) =>
Doing req.params
returns an empty array, whereas req.query.uid
when the url contains query strings works.
2 Answers
Reset to default 8If your URL is "www.a./users/uid", "uid" will be part of req.path. You can split that on '/' to get the uid as the last element of the array returned by split.
You can only use req.params
with Cloud Functions for Firebase when you're exporting an entire Express app that defines a router that uses a placeholder for the element in the path you want to extract.
Alternatively, you can use express in firebase. and use req.param to get the value.
I have a url in the form www.a/users/uid, I want to get uid
.
Assume a function :
exports.smartlink = functions.https.onRequest((req, res) =>
Doing req.params
returns an empty array, whereas req.query.uid
when the url contains query strings works.
I have a url in the form www.a./users/uid, I want to get uid
.
Assume a function :
exports.smartlink = functions.https.onRequest((req, res) =>
Doing req.params
returns an empty array, whereas req.query.uid
when the url contains query strings works.
2 Answers
Reset to default 8If your URL is "www.a./users/uid", "uid" will be part of req.path. You can split that on '/' to get the uid as the last element of the array returned by split.
You can only use req.params
with Cloud Functions for Firebase when you're exporting an entire Express app that defines a router that uses a placeholder for the element in the path you want to extract.
Alternatively, you can use express in firebase. and use req.param to get the value.
本文标签: javascriptFirebase Functions ExpressHow to get URL params with pathsStack Overflow
版权声明:本文标题:javascript - Firebase Functions Express : How to get URL params with paths - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745493156a2153052.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论