Thanks sander I did not configure CORS very well on the server. Now I have 
fixed it and its returning response but the response is not showing on the 
page I had to inspect the code and found out it returned object in 4 
places. I think I will have to serialize it to the object I have on the 
client. I dont know how to go about that. I have "Category" class on the 
server I created "Category" with the same fields in my angular like this 

export class Category {
  id: number;
  name: string;
}

I called the server like this 

getCategories (): Observable<Category[]> {
  return 
this.http.get<Category[]>('http://localhost:56757/api/product/categories')
    .pipe(
      tap(categories` => this.log(`fetched categories`)),
      catchError(this.handleError('getCategories', []))
    );
}


HTML :

 <ul>
  <li *ngFor="let cat of categories">
    <span class="badge">{{cat.id}}</span> {{cat.name}}
  </li>
</ul>

On Monday, November 20, 2017 at 1:47:03 PM UTC+1, olabanji tajudeen wrote:
>
> Hi everyone I am new to angular. My first project trying to get data from 
> an API throws this error "Http failure response for (unknown url): 0 
> Unknown Error". Please I want to know what could have been causing this 
> error. Thanks in advance for your response.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to