@angular/common/http#HttpBackend TypeScript Examples
The following examples show how to use
@angular/common/http#HttpBackend.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: app.module.ts From auth0-angular with MIT License | 6 votes |
@NgModule({
declarations: [
AppComponent,
ProtectedComponent,
UnprotectedComponent,
ChildRouteComponent,
NestedChildRouteComponent,
ErrorComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
ReactiveFormsModule,
HttpClientModule,
// This playground has been configured by default to use dynamic configuration.
// If you wish to specify configuration to `forRoot` directly, uncomment `authConfig`
// here, and comment out the APP_INITIALIZER config in the providers array below.
AuthModule.forRoot(/* authConfig */),
],
providers: [
{
provide: APP_INITIALIZER,
useFactory: configInitializer,
deps: [HttpBackend, AuthClientConfig],
multi: true,
},
{ provide: HTTP_INTERCEPTORS, useClass: AuthHttpInterceptor, multi: true },
],
bootstrap: [AppComponent],
})
export class AppModule {}
Example #2
Source File: app.module.ts From auth0-angular with MIT License | 6 votes |
/**
* Provides configuration to the application
* @param handler The HttpBackend instance used to instantiate HttpClient manually
* @param config The AuthConfigClient service
*/
function configInitializer(
handler: HttpBackend,
config: AuthClientConfig
): () => Promise<any> {
return () =>
new HttpClient(handler)
.get('/assets/config.json')
.toPromise()
.then((loadedConfig: any) => config.set(loadedConfig)); // Set the config that was loaded asynchronously here
}
Example #3
Source File: http-client.module.ts From nativescript-http with MIT License | 6 votes |
@NgModule({
providers: [
NSFileSystem,
NsHttpBackEnd,
NSHTTPXhr,
{ provide: HttpBackend, useExisting: NsHttpBackEnd },
],
imports: [
HttpClientModule,
],
exports: [
HttpClientModule,
]
})
export class NativeScriptHttpClientModule {
}