@dlcs/provider-angular-http
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

DLCS Angular HttpClient Provider

status npm

Resource provider for Angular HttpClient.

Configuration

Name Default value Usage
server.address '' Default server address from remote protocol
server.responseType 'json' Default response type
server.contentType 'application/json' Default content type
assets.address '' Default address from assets protocol

Supported protocol

  • remote for access default server defined in Configuration.
  • assets for access staic files defined in Configuration.
  • http for access http address.
  • https for access https address.

Request parameters

Name Default value Description
responseType Set by configuration Respnse type
contentType Set by configuration Content type
method XHRMethod.GET Request http method.
headers undefined Extra headers
querys undefined URL query parameters
body undefined Request body, only affects POST/PUT/PATCH
timeout undefined Request timeout, do not set this value or set to 0 to disable timeout.

Structure defined as AngularHttpRequestParams.

Supported mode

Protocol Asynchronized Synchronized Request Submit Delete
remote ×
assets × × ×
http ×
https ×

Injectors

Timepoint Data structure Data description Request method
BeforeSend AngularHttpRequestData Request parameters Request/Submit/Delete
AfterSent Observable<any> Response from HttpClient Request/Submit/Delete

See AngularHttpRequestData's definition.

Example

resourceManager.registerProtocol(new AngularHttpProtocol(this.httpClient)); // Angular HttpClient from Angular DI
// Request data
resourceManager.request.to(`http://www.google.com`).tag('google').send();
// Request using default server
http.config.server.address = 'http://www.a.org';
resourceManager.request.to(`remote:///test.txt`).tag('test').send();
// Request static file
http.config.assets.address = '/assets';
resourceManager.request.to(`assets:///test.txt`).tag('test_local').send();
// POST data
resourceManager.request.to(`http://www.test.org`).param({ method: XHRMethod.POST }).tag('google').send();

Readme

Keywords

none

Package Sidebar

Install

npm i @dlcs/provider-angular-http

Weekly Downloads

1

Version

1.2.2

License

MIT

Unpacked Size

34.7 kB

Total Files

28

Last publish

Collaborators

  • lundarl_gholoi