Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix async #1819

Merged
merged 1 commit into from
Dec 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/en/core/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion docs/source/en/tutorials/restful.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion docs/source/zh-cn/core/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion docs/source/zh-cn/tutorials/restful.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down