Paldom / angular2-rest

Angular2 HTTP client to consume RESTful services. Built with TypeScript.
MIT License
248 stars 72 forks source link

querystring stringification patch #1

Closed Discountrobot closed 8 years ago

Discountrobot commented 8 years ago

Came across a minor issue when passing objects as querystrings :) this patch includes fixes for:

Paldom commented 8 years ago

Thanks @Discountrobot, both are great considerations! :) I've merged, but in fact, I have some thoughts about this issue:

What do you think?

ps: sorry for Travis error, I'm working on CI build (and test).

Discountrobot commented 8 years ago

After reviewing, i actually agree - that stringifying should happen outside of the base rest-client :)

As for the filtering, marking a query as optional, will still add it to the paramBuilder descriptor - regardless of the value

    @GET("/")
    public find( @Query("filter") filter?: IFilter): Promise<any> { return null }
   // SomeService.find() => http://localhost?filter=undefined
   // SomeService.find('something') => http://localhost?filter=something

Also, why have you chosen to implement the IRequest interface, rather than implementing the https://angular.io/docs/ts/latest/api/http/RequestOptions-class.html ?

Paldom commented 8 years ago

I'll look after why optional params not working, it was correct before, without any filtering.
You're right, RequestOptions is much better for request encapsulation (and later, for response). The only reason for using custom IRequest is not having enough time to look after the Angular2 way for that :)