Skip to content

Variable: OnMapResponse

ts
const OnMapResponse: (options?) => MethodDecorator;

Defined in: packages/core/src/decorators/lifecycle.decorators.ts:171

Hook called to map response

Parameters

ParameterTypeDescription
options?{ before?: boolean; }-
options.before?booleanInsert before other hooks

Returns

MethodDecorator

See

https://elysiajs.com/essential/life-cycle.html#on-map-response

Example

typescript
@Controller('/users')
export class UserController {
  @OnMapResponse()
  async formatResponse(context: Context) {
    return new Response(JSON.stringify(context.response), {
      headers: { 'Content-Type': 'application/json' }
    });
  }
}

Released under the MIT License.