javascript - Firebase Functions Express : How to get URL params with paths - Stack Overflow

I have a url in the form www.ausersuid, I want to get uid.Assume a function : exports.smartlink = fun

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.

Share Improve this question asked Mar 30, 2018 at 11:42 RelmRelm 8,28520 gold badges69 silver badges114 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

If 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信