我想在 Firebase 云功能中发出发布请求并将数据发送到正文。 默认是get请求还是post请求?
var functions = require('firebase-functions');
exports.tryfunction= functions.https.onRequest((req, res) => {
console.log(req.body) // or it should be req.query
});
我怎么知道和决定它是什么方法?
最佳答案
我只是分享简单的代码部分。我是这样使用的。
const functions = require('firebase-functions');
exports.postmethod = functions.https.onRequest((request, response) => {
if(request.method !== "POST"){
response.send(405, 'HTTP Method ' +request.method+' not allowed');
}
response.send(request.body);
});
希望对你有帮助。
关于http post请求firebase云功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49845813/