Closed
Description
What problem does this feature solve?
Because now the render.renderToString function return nothing, but its a async function, i need return response in its callback, it will lead to bug in koa. I have to wrap it to a function return promise to let it to work. Something like this:
function render(renderer) {
let resolve;
const promise = new Promise(r => resolve = r);
renderer.renderToString(context, (err, html) => {
resolve(html);
});
return promise;
}
server.get('*', async ctx => {
const res = await render(renderer);
ctx.status = 200;
ctx.body = res;
})
Maybe the render.renderToString return a promise will be better ?
What does the proposed API look like?
koa2:
server.get('*', async ctx => {
const res = await renderer.renderToString(context);
ctx.status = 200;
ctx.body = res;
})