angular-async-http
Angular 4 Async HTTP client in typescript with promises, interceptors, and timeouts. Note: Production Ready! (Well tested)
Installation
npm install angular-async-http --save
Example
;;; ;;
Using it in your component
app.module.ts
todo.component.ts
// You need some or all of the following rxjs imports for Promise and Observable.;;;;;;private handleErrorerror: any: Promise<any>}
API Docs
RestClient
Methods:
getServiceId(): string
: returns the serviceId of the RestClientgetBaseUrl(): string
: returns the base url of RestClientgetDefaultHeaders(): Object
: returns the default headers of RestClient in a key-value pair
Class decorators:
@Client(args:{serviceId?: string, baseUrl?: string, headers?: any})
Method decorators:
@Get(url: String)
@Post(url: String)
@Put(url: String)
@Patch(url: String)
@Delete(url: String)
@Head(url: String)
@Headers(headers: Object)
@Map(mapper:(resp : any)=>any)
@OnEmit(emitter:(resp : Observable<any>)=>Observable<any>)
@Timeout(timeout: number)
Parameter decorators:
@Path(name: string, value?:any|{value?:any})
@Query(name: string, value?:any|{value?:any,format?:string})
@Header(name: string, value?:any|{value?:any,format?:string})
@Body
Collection Format
Determines the format of the array if type array is used. (used for @Query
and @Header
) Possible values are:
Format.CSV
- comma separated valuesfoo,bar
.Format.SSV
- space separated valuesfoo bar
.Format.TSV
- tab separated valuesfoo\tbar
.Format.PIPES
- pipe separated valuesfoo|bar
.Format.MULTI
- corresponds to multiple parameter instances instead of multiple values for a single instancefoo=bar&foo=baz
. This is valid only for parameters in "query" or "formData".
Default value is Format.CSV
.
Contributors
Brought to you by many contributors, including:
TrustPortal Solutions Ltd http://trustportal.org
Yavin Five
deblockt
Dmitry-Gorbenko
Maxxton Group http://www.maxxton.com
Domonkos Pal : Paldom
Discountrobot
TN-Kirontech
LeFinc
mmrath http://www.mmrath.com
steven166
Mayur Patel : mayur-novus
License
MIT