Why is the result of using await to obtain promise in ejs [object promise]?
xiaowang-create opened this issue · 3 comments
xiaowang-create commented
Our company's native development encountered this problem, help!
RyanZim commented
Without any example code, it's hard for me to figure out what issue you're encountering.
ben1one commented
Try set async to false
const html = await ejs.renderFile(
path.resolve("src/template", "index.ejs"),
{},
{ async: false, cache: false },
);
mde commented
The async
setting needs to be set to true, yes. Also worth noting that only the file I/O is async. It's generally more efficient if you can to do your I/O up front and keep template strings in a cache if you can.