diff --git a/docs/source/en/basics/router.md b/docs/source/en/basics/router.md index 035742f257..532c8cf0eb 100644 --- a/docs/source/en/basics/router.md +++ b/docs/source/en/basics/router.md @@ -23,7 +23,8 @@ module.exports = app => { // app/controller/user.js class UserController extends Controller { async info() { - this.ctx.body = { + const { ctx } = this; + ctx.body = { name: `hello ${ctx.params.id}`, }; } diff --git a/docs/source/zh-cn/basics/router.md b/docs/source/zh-cn/basics/router.md index aa4aa51ff6..a4b3b5ad1a 100644 --- a/docs/source/zh-cn/basics/router.md +++ b/docs/source/zh-cn/basics/router.md @@ -25,7 +25,7 @@ module.exports = app => { class UserController extends Controller { async info() { const { ctx } = this; - this.ctx.body = { + ctx.body = { name: `hello ${ctx.params.id}`, }; } diff --git a/index.d.ts b/index.d.ts index 84df0d45d6..5ae17f4cea 100644 --- a/index.d.ts +++ b/index.d.ts @@ -120,7 +120,7 @@ interface Request extends KoaApplication.Request { // tslint:disable-line */ query: { [key: string]: string }; - body: RequestArrayBody | RequestObjectBody; + body: any; } interface Response extends KoaApplication.Response { // tslint:disable-line @@ -471,7 +471,7 @@ declare interface EggApplication extends KoaApplication { // tslint:disable-line * Keep the same api with httpclient.request(url, args). * See https://github.com/node-modules/urllib#api-doc for more details. */ - curl(url: string, opt: RequestOptions): Promise; + curl(url: string, opt?: RequestOptions): Promise; /** * Get logger by name, it's equal to app.loggers['name'], but you can extend it with your own logical @@ -733,7 +733,7 @@ export interface Context extends KoaApplication.Context { * Keep the same api with httpclient.request(url, args). * See https://github.com/node-modules/urllib#api-doc for more details. */ - curl(url: string, opt: RequestOptions): Promise; + curl(url: string, opt?: RequestOptions): Promise; /** * Get logger by name, it's equal to app.loggers['name'], but you can extend it with your own logical