diff --git a/docs/source/en/core/error-handling.md b/docs/source/en/core/error-handling.md index db641e3925..a8862fcba3 100644 --- a/docs/source/en/core/error-handling.md +++ b/docs/source/en/core/error-handling.md @@ -148,7 +148,7 @@ If you want a customized 404 response, you only need to create a middleware to h ```js // app/middleware/notfound_handler.js module.exports = () => { - return async notFoundHandler(ctx, next) { + return async function notFoundHandler(ctx, next) { await next(); if (ctx.status === 404 && !ctx.body) { if (ctx.acceptJSON) { diff --git a/docs/source/en/tutorials/restful.md b/docs/source/en/tutorials/restful.md index e71660d584..0f077e3bea 100644 --- a/docs/source/en/tutorials/restful.md +++ b/docs/source/en/tutorials/restful.md @@ -157,7 +157,7 @@ class TopicController extends Controller { // status = 422 exception will be thrown if not passing the parameter validation ctx.validate(createRule); // call service to create a topic - const id = yield ctx.service.topics.create(ctx.request.body); + const id = await ctx.service.topics.create(ctx.request.body); // configure the response body and status code ctx.body = { topic_id: id, diff --git a/docs/source/zh-cn/core/error-handling.md b/docs/source/zh-cn/core/error-handling.md index 3a3fc6e8a1..5023d29af6 100644 --- a/docs/source/zh-cn/core/error-handling.md +++ b/docs/source/zh-cn/core/error-handling.md @@ -146,7 +146,7 @@ module.exports = { ```js // app/middleware/notfound_handler.js module.exports = () => { - return async notFoundHandler(ctx, next) { + return async function notFoundHandler(ctx, next) { await next(); if (ctx.status === 404 && !ctx.body) { if (ctx.acceptJSON) { diff --git a/docs/source/zh-cn/tutorials/restful.md b/docs/source/zh-cn/tutorials/restful.md index e8ed0872d3..2e91a80878 100644 --- a/docs/source/zh-cn/tutorials/restful.md +++ b/docs/source/zh-cn/tutorials/restful.md @@ -158,7 +158,7 @@ class TopicController extends Controller { // 如果参数校验未通过,将会抛出一个 status = 422 的异常 ctx.validate(createRule); // 调用 service 创建一个 topic - const id = yield ctx.service.topics.create(ctx.request.body); + const id = await ctx.service.topics.create(ctx.request.body); // 设置响应体和状态码 ctx.body = { topic_id: id,