【问题标题】:Calling another api in firebase functions在 firebase 函数中调用另一个 api
【发布时间】:2021-06-18 01:10:41
【问题描述】:

我是 Firbase 功能、服务器、快递的新手。
我无法进行调用 https 地址之外的调用函数。 (出口?)
这个地址是测试用的,需要调用支付接口。
我需要设置 VPS 还是 gcloud 设置? 我使用 node express,并设置 CORS。

app.get('/test', async (_, res) => {
  console.log('test started');
  try {
    fetch('https://www.scrum.org/open-assessments')
      .then((resp) => {
        console.log('resp', resp);
        res.status(200).send(' OK ');
      });
  } catch (error) {
    res.status(500).send(error);
  }
});

【问题讨论】:

  • 您遇到什么错误?您是付费套餐还是免费套餐?
  • Blaze 计划。我得到了 500 错误,这意味着 try 失败..
  • 是的,但error 变量中有什么?你有更具体的信息吗?您不需要为来自云功能的出站请求获取 VPS 或设置 CORS。
  • 感谢您的回复。问题已通过node-fetch 解决。我不知道为什么fetch 不起作用..

标签: node.js firebase google-cloud-functions


【解决方案1】:

问题已通过 node-fetch 模块解决..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-10
    • 2017-03-07
    • 2019-09-17
    • 2013-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多