I'm working with Angular 7.0.7 Angular Universal project. All seems to be working great, except for the SEO part. I followed a lot of tutorials, such as https://blog.worldline.tech/2018/03/08/angular-universal.html
The node server is supposed to do the GET part to display the page with the information already, but when I use https://search.google.com/structured-data/testing-tool none of that GET request is show.
import { HttpClient } from "@angular/common/http";
import { Component, OnInit, Inject } from "@angular/core";
import { Title, TransferState, makeStateKey } from "@angular/platform-browser";
export class TestComponent implements OnInit {
test;
constructor(
@Inject(PLATFORM_ID) private _platformId: Object,
private titleService: Title,
private transferState: TransferState,
private http: HttpClient
) {}
ngOnInit() {
this.test = [];
let myTransferStateKey = makeStateKey<any>("myDatas");
if (this.transferState.hasKey(myTransferStateKey)) {
this.test = this.transferState.get(myTransferStateKey, {});
this.transferState.remove(myTransferStateKey);
console.log("Test w/o GET");
console.log(this.test);
console.log("transferstate key");
console.log(myTransferStateKey);
} else {
this.http
.get("https://reqres.in/api/users?page=2")
.subscribe(response => {
this.test = response["data"];
this.transferState.set(myTransferStateKey, this.test);
console.log("Test with GET");
console.log(this.test);
console.log("transferstate key");
console.log(myTransferStateKey);
});
}
}
}
<div class="container">
<div class="row">
<div class="col" *ngFor="let item of test">
{{item.email}}
</div>
</div>
</div>
I expected the https://search.google.com/structured-data/testing-tool to show the list of users but it doesn't and instead it shows a <!---->
.
I also tried doing a curl but is the same thing.
What I'm doing wrong? Thank you.