Trabajo con las funciones de la nube de Google y la mensajería en la nube en Firebase. Sin embargo, cuando trato de usar las funciones Async/Await, aparece un error: error Parsing error: Unexpected token => Trabajo con Node.js v16.
Aquí está mi código:
const functions = require("firebase-functions"); // const mess = require("firebase/messaging"); const admin = require("firebase-admin"); exports.sendListenerPushNotificationProductUpdate = functions.database .ref("Products/{product}/type/") .onUpdate(async (snapshot, context) => { ... const tokensSnapshot = await Promise.resolve(getDeviceTokensPromise); console.log("TOKEN: " + JSON.stringify(tokensSnapshot)); // Check if there are any device tokens. if (!tokensSnapshot.hasChildren()) { return functions.logger.log( "There are no notification tokens to send to." ); } ... // Listing all tokens as an array. const tokens = Object.keys(tokensSnapshot.val()); // Send notifications to all tokens. const response = await admin.messaging().sendToDevice(tokens, payload); // For each message check if there was an error. const tokensToRemove = []; return Promise.all(tokensToRemove); });¿ getDeviceTokensPromise devuelve una Promise ? Si es así, esa línea debería ser
const tokensSnapshot = await getDeviceTokensPromise()