gpt4 book ai didi

node.js - 如何从 firebase 函数中的 "get request"获取参数?

转载 作者:行者123 更新时间:2023-12-03 12:18:47 25 4
gpt4 key购买 nike

我知道 firebase https.onRequest 中的请求参数对应于 Express 响应。

我想使用这种格式运行云函数(本地测试):

http://localhost:5000/test-2c6e8/us-central1/coins?userid=1

所以,现在我只想从云函数中获取 userId 参数。我写的测试函数是:

exports.coins = functions.https.onRequest((request, response) => 
{
var db = admin.firestore();
response.json({query: JSON.stringify(request.query),
params: JSON.stringify(request.params),
body: JSON.stringify(request.body)});
response.end();
});

这是我得到的输出:

query   "{}"
params "{\"0\":\"\"}"
body "{}"

我试过很多东西都没有运气。为什么会这样?

最佳答案

简短的回答是req.query.name_of_the_parameter;对于长答案,您可以阅读 here .

关于node.js - 如何从 firebase 函数中的 "get request"获取参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56291645/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com