我正在尝试获取请求查询参数和网址firebase functions
。
这是我正在使用的代码
firebase.json
{
"hosting": {
"public": "build",
"rewrites": [{
"source": "/getCoins",
"function": "getCoins"
}]
}
}
Using "firebase-functions": "^2.3.1"
in package.json
functions/index.js
'use strict';
const functions = require('firebase-functions');
exports.getCoins = functions.https.onRequest((req, res) => {
console.log(req.query); // [object Object]
console.log(req.query.repeat); // empty
console.log(req.url); // '/'
console.log(req.originalUrl); // '/'
res.sendStatus(200);
});
在我的 Windows 命令提示符中启动 firebase 功能firebase serve --only functions
。当它开始提供数据时http://localhost:5000
,我正在尝试请求http://localhost:5000/coins-app/us-central1/getCoins?repeat=4
我在命令提示符中没有收到任何错误,但只能看到上面的注释行functions/index.js
code.
你应该跑firebase serve
并要求http://localhost:5000/getCoins?repeat=4 http://localhost:5000/getCoins?repeat=4 .
functions.https.onRequest()
无法直接接受查询字符串参数。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)