I am trying to get some data from the server through REST API service. Inside the service.ts I have below,
getCategories(): Observable<Category> {
// Http Options
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Access-Control-Allow-Origin' : '*',
'Access-Control-Allow-Methods' : 'POST'
})
};
return this.http.post<Category>(this.apiURL+'api', JSON.stringify({"type":"get_categories"}), httpOptions )
.pipe(
retry(0),
//catchError(this.handleError)
)
}
Which again shows the error as below,
Object { headers: {…}, status: 0, statusText: "Unknown Error", url: "http://localhost/test/api", ok: false, name: "HttpErrorResponse", message: "Http failure response for http://localhost/test/api: 0 Unknown Error", error: error }
I have been referring lots of posts, but nothing helps.