Skip to content

Cannot override query parameter default value in controller method #1408

@lifan0127

Description

@lifan0127

Description / Steps to reproduce / Feature proposal

See this example from the documentation: http://loopback.io/doc/en/lb4/Controllers.html#writing-controller-methods

  @get('/messages')
  async list(@param.query.number('limit') limit = 10): Promise<HelloMessage[]> {
    if (limit > 100) limit = 100; // your logic
    return await this.repository.find({limit}); // a CRUD method from our repository
  }

Current Behavior

The limit parameter is always 10, regardless of what value is supplied through query parameter.

Expected Behavior

Be able to change limit via query parameter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions