我的Firebase功能有问题。我收到以下错误。
SyntaxError:无法在模块外部使用import语句
下面是我的代码:
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);
});
如何导入Firebase函数?
您正在使用TypeScript还是原始JavaScript?使用普通的JavaScript时,您需要使用require,例如:
const functions = require('firebase-functions');
另外,将功能更改为与以下相同:
exports.weeklyReminder = functions.pubsub.schedule('every Thursday 21:00').onRun(
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句