gizm0bill / angular2-rest-client

MIT License
8 stars 5 forks source link

How to specify global query parameters? #5

Closed write2sv closed 7 years ago

write2sv commented 7 years ago

Hi There!

Is there a way to add a set of Query parameters that can go with all requests in the ApiClient class. Just like the way we have global Headers.

For example: I need to send timezone parameter to our server for all the requests that we are making. Instead of adding it to all my request methods I would love to have it added as a global.

gizm0bill commented 7 years ago

Hello, That is not possible at the moment... But I will update it with this feature this Tuesday/Wednesday along with support for angular 4.x.x, I also need these for a current project :)

write2sv commented 7 years ago

Sounds great! Thanks for the quick response.

gizm0bill commented 7 years ago

I pushed some changes to the repo, v. 1.3.1 you can use like

import { Query, ... } from 'angular2-rest-client';
...
@Query({ 'from-private': function() { return this._queryString; /* might as well be injected */ } })
@Query({ something: 'some-value', 'something-else': 'some-other-value' })
class ApiClient extends AbstractApiClient
{
  @GET() someCall( @Query('someParam') someValue: string ) ...

@write2sv see if it is what you needed, thanks!

gizm0bill commented 7 years ago

closing because of inactivity