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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745493157a4630076.html
评论列表(0条)