I am attempting to implement the following logic in a Google Cloud Function. When I run this function using the emulator, I consistently encounter the error message
⚠ functions: TypeError: Cannot read property 'post' of undefined
I have tried importing the Axios package in various ways without success. Could this issue be related to my code or is there a configuration setting in Firebase that I am overlooking?
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}`);
});
});