Skip to content

Commit 9197b6c

Browse files
committed
fix: TransferHttpCacheModule - work!
1 parent dc632fb commit 9197b6c

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

src/app/app.browser.module.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import { NgModule } from '@angular/core';
33
import { BrowserModule, BrowserTransferStateModule } from '@angular/platform-browser';
44
// libs
5-
import { TransferHttpCacheModule } from '@nguniversal/common';
65
import { REQUEST } from '@nguniversal/express-engine/tokens';
76
// shared
87
import { CookieStorage } from '@shared/for-storage/browser.storage';
@@ -25,7 +24,6 @@ export function getRequest(): any {
2524
bootstrap: [AppComponent],
2625
imports: [
2726
BrowserModule.withServerTransition({ appId: 'my-app' }),
28-
TransferHttpCacheModule,
2927
BrowserTransferStateModule,
3028
AppModule,
3129
TranslatesBrowserModule,

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { BrowserModule } from '@angular/platform-browser';
66
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
77
// libs
88
import { CookieService } from 'ngx-cookie-service';
9+
import { TransferHttpCacheModule } from '@nguniversal/common';
910
// shared
1011
import { SharedModule } from '@shared/shared.module';
1112
import { TranslatesService } from '@shared/translates';
@@ -20,6 +21,7 @@ export function initLanguage(translateService: TranslatesService): Function {
2021
@NgModule({
2122
imports: [
2223
BrowserModule.withServerTransition({ appId: 'my-app' }),
24+
TransferHttpCacheModule,
2325
HttpClientModule,
2426
RouterModule,
2527
AppRoutes,

src/app/transfer-back/transfer-back.component.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ <h1>{{ "back-http.title" | translate }}</h1>
77
<pre *ngIf="result; else noResult">
88
{{ result | json }}
99
</pre>
10+
<pre *ngIf="resultHttpClient; else noResult">
11+
{{ resultHttpClient | json }}
12+
</pre>
1013
<ng-template #noResult>
1114
<p>{{ "loading" | translate }}...</p>
1215
</ng-template>
@@ -16,4 +19,4 @@ <h1>{{ "back-http.title" | translate }}</h1>
1619
{{ resultPost | json }}
1720
</pre>
1821
<br/>
19-
<strong>{{ "back-http.original-url" | translate }}</strong> {{ baseUrl }}
22+
<strong>{{ "back-http.original-url" | translate }}</strong> {{ baseUrl }}

src/app/transfer-back/transfer-back.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@ import { Component, OnInit, Inject } from '@angular/core';
22

33
import { AppStorage } from '@shared/for-storage/universal.inject';
44
import { TransferHttpService } from '@gorniv/ngx-transfer-http';
5+
import { HttpClient } from '@angular/common/http';
56

67
@Component({
78
selector: 'app-transfer-back',
89
templateUrl: './transfer-back.component.html'
910
})
1011
export class TransferBackComponent implements OnInit {
1112
public result: any;
13+
public resultHttpClient: any;
1214
public resultPost: any;
1315

1416
constructor(private http: TransferHttpService,
17+
private httpClient: HttpClient,
1518
@Inject(AppStorage) private appStorage: Storage,
1619
@Inject('ORIGIN_URL') public baseUrl: string) {
1720
console.log(`ORIGIN_URL=${baseUrl}`);
@@ -21,6 +24,9 @@ export class TransferBackComponent implements OnInit {
2124
this.http.get('https://reqres.in/api/users?delay=3').subscribe(result => {
2225
this.result = result;
2326
});
27+
this.httpClient.get('https://reqres.in/api/users?delay=3').subscribe(result => {
28+
this.resultHttpClient = result;
29+
});
2430
this.http.post('https://reqres.in/api/users', JSON.stringify({
2531
'name': 'morpheus',
2632
'job': 'leader'

0 commit comments

Comments
 (0)