【发布时间】:2018-12-02 14:48:33
【问题描述】:
我正在尝试使用 fs.readFile('../emailTemplates/template.html') 从 index.ts 读取 html 文件
我的文件夹:
--src
--index.ts
--UsersFunctions
--UserFunctions.ts
--emailTemplates
--template.html
来自 index.ts :
import * as UsersFunctions from './UsersFunctions/UsersFunctions';
export const newUserRegister = UsersFunctions.onCreateNewUser;
来自 UsersFunctions.ts
export const onCreateNewUser = functions.firestore.document('users/allUsers/usersData/{userId}').onCreate(async (snap, context) => {
fs.readFile("../emailTemplates/template.html", {encoding: 'utf-8'}, (err, html) => {
if (err) {
console.log(err);
}
else {
}
});
}
我从 firebase 函数中得到一个错误:
Error: ENOENT: no such file or directory, open '../emailTemplates/template.html'
at Error (native)
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: 'user_code/lib/emailTemplates/newUserRegisterHtmlTemplate.html'
我只想发送一封带有 html 模板的电子邮件 也许还有另一种方法可以做到这一点? 我厌倦了搜索,但没有找到关于带有打字稿的 frirebase 功能的电子邮件模板
【问题讨论】:
标签: typescript firebase google-cloud-functions fs