Website: https://sunny-mousse-bc9ae9.netlify.app
Hello, when I develop a scheduled function and try to use axios on it, it returns this error:
ERROR Uncaught Exception {"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module '/var/task/node_modules/axios/dist/node/axios.cjs'","stack":["Runtime.ImportModuleError: Error: Cannot find module '/var/task/node_modules/axios/dist/node/axios.cjs'"," at _loadUserApp (file:///var/runtime/index.mjs:997:17)"," at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1032:21)"," at async start (file:///var/runtime/index.mjs:1195:23)"," at async file:///var/runtime/index.mjs:1201:1"]}
This is the code:
import { schedule } from "@netlify/functions";
import axios from 'axios'
import { Webhook } from 'discord-webhook-node';
const hook = new Webhook("https://discord.com/api/webhooks/mywebhookid");
const handler = async function (event, context) {
var date = new Date();
date = date.getUTCFullYear() + '-' +
('00' + (date.getUTCMonth() + 1)).slice(-2) + '-' +
('00' + date.getUTCDate()).slice(-2) + ' ';
try {
const response = await axios.get(
"theURLworking"
)
hook.send("Buena conexion. <@286402429258301440>")
} catch (error) {
hook.send("Fallo en la conexión. <@286402429258301440>")
}
};
exports.handler = schedule("*/1 * * * *", handler);