export class BannerComponent implements OnInit {
constructor(private http: HttpClient) { }
banners: any;
url = 'localhost:9000/api/banners';
ngOnInit() {
this.getBanners();
}
getBanners(): any {
return this.http.get(this.url).subscribe(res=>{
this.banners = res;
})
}
}
I am getting an unknown error with status code as 0. Where as in Postman I am getting data.
CORS
- Cross Origin Resource Sharing problem. Download any browser extension to enable it. Or make an interceptor that adds appropriate header before making api calls.