Estoy tratando de enviar una solicitud POST a través de la función de nube de axios y firebase mientras que el cuerpo de la solicitud en axios contiene datos de los cambios ocurridos en la base de datos en tiempo real usando las funciones, pero cada vez que implemento mi código aparece el error:
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.Soy bastante nuevo en las funciones de Firebase, así que realmente no sé lo que estoy haciendo aquí, incluso después de investigar un poco. Código:
const functions = require("firebase-functions"); const axios = require("axios"); exports.newNodeDetected = functions.database .ref("Orders/{userId}/{customerId}/{ordernum}/customername") .onCreate((snapchot, context) => { const order = snapchot.val(); const userId = context.params.userId; console.log(userId + "AND CUS NAME IS" + order); axios.post("http://something.com/data.php", { username: userId, title: "ttl", message: "msg", }) .then(function(response) { console.log(response); }) .catch(function(error) { console.log(error); }); });