Firebase Cloud函数对外部API的HTTP请求

时间:2019-03-19 21:28:18

标签: firebase api google-cloud-functions

我想构建一个从API请求返回结果的云函数。

import * as functions from 'firebase-functions';

exports.getData = functions.https.onRequest(async (request, response) => {
 const result = await fetch("3RD PARTY API URL")
 response.send(result);
});

由于某种原因,我得到了

Error: could not handle the request

是什么原因造成的? 我认为这与未正确发送请求或未正确处理异步代码有关

0 个答案:

没有答案