我尝试在google cloud函数中托管以下逻辑。当我使用模拟器执行此函数时,我总是得到⚠ functions: TypeError: Cannot read property 'post' of undefined
我尝试以不同的方式导入Axios包,但没有成功。这是与我的代码有关还是我缺少了一些firebase配置?
import axios from "axios";
export const sendSlackMessage = functions.https.onRequest(async (request, response) => {
const slackUrl = functions.config().slackconfig.webhookurl;
await axios.post(slackUrl, request.body)
.then((value) => {
console.log(value.data);
response.sendStatus(200);
})
.catch((reason) => {
response.send(`Failed, ${reason}`);
});
});
1条答案
按热度按时间tp5buhyn1#
确保已在函数目录中安装了axios