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

Provide defaults to params #32

Open
AILazerka opened this issue Oct 12, 2017 · 2 comments
Open

Provide defaults to params #32

AILazerka opened this issue Oct 12, 2017 · 2 comments
Milestone

Comments

@AILazerka
Copy link

Such code as following (with default value) is not working:

  @GET('someUrl')
  @Produces<any>()
  public getSomeData(@Query('someParam') someParam: string = 'defaultValue'): Observable<any> {
    return null;
  }

Only tricky implementation will work for now, like:

  public getSomeData(someParam: string = 'defaultValue'): Observable<any> {
    return getSomeDataRemote(status);
  }

  @GET('someUrl')
  @Produces<any>()
  private getSomeDataRemote(@Query('someParam') someParam: string): Observable<any> {
    return null;
  }
@hboylan hboylan changed the title Providing of defaults to params is not working Provide defaults to params Nov 14, 2017
@hboylan hboylan added this to the 1.1.0 milestone Nov 14, 2017
@hboylan
Copy link
Owner

hboylan commented Nov 14, 2017

Not sure how to pass them through the decorator

@akarabach
Copy link
Collaborator

akarabach commented Apr 16, 2018

Hello, I propose to add an additional param to decorator Query.
Like this @Query('someParam', 1) where 1 is default value for someParam.
Your result service method will be

@GET('someUrl')
@Produces<any>()
 public getSomeData(@Query('someParam', 'defaultValue') someParam?: string): Observable<any> {
   return null;
 }

@hboylan What do you think ?

@akarabach akarabach reopened this Apr 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants