'ERROR ReferenceError: XMLHttpRequest is not defined in SSR angular 11
I am working on SSR in Angular version 11. When I call cdn json file that time getting run time error ERROR ReferenceError: XMLHttpRequest is not defined
and not showing data on SSR.
Please help what can I do
abc.component.ts
import { HttpClient } from '@angular/common/http';
import { Component, EventEmitter, Inject, Input, LOCALE_ID, OnInit, Output, PLATFORM_ID } from '@angular/core';
cardInfo: any;
constructor(
private http: HttpClient,
@Inject(LOCALE_ID) public languageId: string,
@Inject(PLATFORM_ID) private platformId,
) {}
ngOnInit(): void {
this.getJsonData().subscribe((res) => {
this.cardInfo = res;
});
}
getJsonData() {
return this.http.get(
`https://cdn.researcher.life/rlife/json/advisory-board-members/advisory-board-members-${this.languageId}-v4.json`,
);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|