http post请求firebase云功能

标签 http firebase post google-cloud-functions

我想在 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/

相关文章:

node.js - 建议 : Tracking HTTP requests with CloudFlare and Ghost

c# - 当我尝试获取 URL 的内容时应用程序卡住

java - 监听器中的 Firebase 监听器已跳过

jquery - Ajax Post请求不一致,为什么?

http - 使用 HTTP Post 从客户端流式传输数据

json - 如何解析 Json 对象并在 scala 中使用它的变量

php - Angular2 http.post 表单值到 php 服务器

android - 在android中获取java.lang.NullPointerException

firebase - 使用 StreamBuilder 时如何将 serverTimestamp 转换为 String

php - 从 $_POST 数组多次 INSERT INTO MySQL