Not able to figure out why the response is coming as null
.
When tested with mock data, it works perfectly fine but when I'm trying to hit our API which is hosted in AWS EC2, the response comes as null
and the error message comes in the console as follows
Cross-Origin Read Blocking (CORB) blocked cross-origin response http://example.com/search/api?limit=10&offset=10 with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.
However, I verified in the browser's Network tab, It shows 200 OK
. Also, I verified this API call with Postman client and the data is being shown.
I tried various ways of disabling the web security option in Chrome browser but no luck. I also have CORS extension in my Chrome browser.
Could anyone please guide what I'm doing wrong here.
Service
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class SearchService {
searchUrl = 'http://example.com/search/api?limit=10&offset=10'
mockDataUrl = 'https://jsonplaceholder.typicode.com/posts';
constructor(private httpClient: HttpClient) { }
getMockData() {
return this.httpClient.get(this.mockDataUrl);
}
getSearchData() {
return this.httpClient.get(this.searchUrl);
}
}
Component
export class AppComponent implements OnInit {
ngOnInit() {
this.searchService.getSearchData().subscribe(
(response) => { console.log(response); }
);
}
}