Skip to content

Commit

Permalink
fix: TransferHttpCacheModule - work!
Browse files Browse the repository at this point in the history
  • Loading branch information
Gorniv committed Sep 19, 2018
1 parent dc632fb commit 9197b6c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/app/app.browser.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { NgModule } from '@angular/core';
import { BrowserModule, BrowserTransferStateModule } from '@angular/platform-browser';
// libs
import { TransferHttpCacheModule } from '@nguniversal/common';
import { REQUEST } from '@nguniversal/express-engine/tokens';
// shared
import { CookieStorage } from '@shared/for-storage/browser.storage';
Expand All @@ -25,7 +24,6 @@ export function getRequest(): any {
bootstrap: [AppComponent],
imports: [
BrowserModule.withServerTransition({ appId: 'my-app' }),
TransferHttpCacheModule,
BrowserTransferStateModule,
AppModule,
TranslatesBrowserModule,
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
// libs
import { CookieService } from 'ngx-cookie-service';
import { TransferHttpCacheModule } from '@nguniversal/common';
// shared
import { SharedModule } from '@shared/shared.module';
import { TranslatesService } from '@shared/translates';
Expand All @@ -20,6 +21,7 @@ export function initLanguage(translateService: TranslatesService): Function {
@NgModule({
imports: [
BrowserModule.withServerTransition({ appId: 'my-app' }),
TransferHttpCacheModule,
HttpClientModule,
RouterModule,
AppRoutes,
Expand Down
5 changes: 4 additions & 1 deletion src/app/transfer-back/transfer-back.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ <h1>{{ "back-http.title" | translate }}</h1>
<pre *ngIf="result; else noResult">
{{ result | json }}
</pre>
<pre *ngIf="resultHttpClient; else noResult">
{{ resultHttpClient | json }}
</pre>
<ng-template #noResult>
<p>{{ "loading" | translate }}...</p>
</ng-template>
Expand All @@ -16,4 +19,4 @@ <h1>{{ "back-http.title" | translate }}</h1>
{{ resultPost | json }}
</pre>
<br/>
<strong>{{ "back-http.original-url" | translate }}</strong> {{ baseUrl }}
<strong>{{ "back-http.original-url" | translate }}</strong> {{ baseUrl }}
6 changes: 6 additions & 0 deletions src/app/transfer-back/transfer-back.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ import { Component, OnInit, Inject } from '@angular/core';

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

@Component({
selector: 'app-transfer-back',
templateUrl: './transfer-back.component.html'
})
export class TransferBackComponent implements OnInit {
public result: any;
public resultHttpClient: any;
public resultPost: any;

constructor(private http: TransferHttpService,
private httpClient: HttpClient,
@Inject(AppStorage) private appStorage: Storage,
@Inject('ORIGIN_URL') public baseUrl: string) {
console.log(`ORIGIN_URL=${baseUrl}`);
Expand All @@ -21,6 +24,9 @@ export class TransferBackComponent implements OnInit {
this.http.get('https://reqres.in/api/users?delay=3').subscribe(result => {
this.result = result;
});
this.httpClient.get('https://reqres.in/api/users?delay=3').subscribe(result => {
this.resultHttpClient = result;
});
this.http.post('https://reqres.in/api/users', JSON.stringify({
'name': 'morpheus',
'job': 'leader'
Expand Down

0 comments on commit 9197b6c

Please sign in to comment.