My goal is to retrieve data from the server using a REST API service. The code snippet below is from my service.ts file:
getCategories(): Observable<Category> {
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),
)
}
However, when I run this code, I encounter the following error message:
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 searched through numerous resources but have not found a solution yet.