I'm, having an issue with my Firebase function. I'm getting the below error.
SyntaxError: Cannot use import statement outside a module
below is my code:
import * as functions from 'firebase-functions';
import * as sgMail from '@sendgrid/mail';
sgMail.setApiKey(key);
export const weeklyReminder = functions.pubsub.schedule('every Wednesday 21:00').onRun(async context =>{
const msg = {
to: '[email protected]',
...
};
return sgMail.send(msg);
});
How do you import into firebase functions?
Are you using TypeScript or vanilla JavaScript? With plain JavaScript you'd use require like this:
const functions = require('firebase-functions');
Also, change the function to be the same as the below:
exports.weeklyReminder = functions.pubsub.schedule('every Thursday 21:00').onRun(
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With