首页 > 解决方案 > 从 aws lambda 向 google firebse 函数发送 http 请求

问题描述

我已经设置了 firebase 函数来接收 http 请求,并验证了同样的工作。现在我试图从 aws lambda 函数向 firebase 发送 http 请求。但是在 aws lambda 或 firebase 函数日志中都没有响应。这是我的 aws lambda 代码:

const postData = JSON.stringify({
        "queryresult" : {
          "parameters": {
            "on": "1",
            "device": "1",
            "off": ""
          }
        }
      });

      const options = {
        hostname: 'https://<the firebase function endpoint>',
        port: 443,
        path: '',
        method: 'POST',
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded',
          'Content-Length': Buffer.byteLength(postData)
        }
      };

      const req = https.request(options, postData)
      .then((response) => {
        console.log(response);
      })
      .catch((err) => {
        console.log(err);
      });

      // Write data to request body
      req.write(postData);
      req.end();
    }

这里的承诺部分是假设执行控制台日志,但它没有被执行。有什么我在这里想念的吗。host是我们部署函数时获取的URL。或者是否存在一些与 firebase 或 aws 相关的计划问题。我在火力基地使用火花计划。谢谢你。

标签: amazon-web-servicesfirebasehttprequest

解决方案


推荐阅读