0

I am trying to retrieve data in Angular 7 using Dotnet Core Web Api, I am getting data when i browse localhost url of Api in Google Chrome as shown in image.

enter image description here

When i test Api in postman i am getting this response as shown in image.

enter image description here

On UI side i am getting this error in console as shown in image.

enter image description here

Here Is my service Method for getting data

  GetJobTitle(): Observable<any> {
    debugger;
    return this.http.get(this._baseUrl)
      .pipe(
        map((response: Response) => {
          return response;
        }),
        catchError((error: Response) => {
          return throwError(console.log(error));
        })
      );
  }

And here is component.ts Get Method

  GetAllJobTitle(): void {
    debugger;
    this.jobTitleService.GetJobTitle()
      .subscribe(
        (data: JobTitleModel[]) => {
          this.MyDataSource = new MatTableDataSource();
          this.MyDataSource.data = data;
          console.log("Data retrieved !!!" + data);
        },
        error => {
          console.log('There was an error while retrieving Positions !!!' + error);
        });
  }

I googled it but couldn't find any solution. I have also added CORS in Api. Can anyone suggest me what am i missing here or what i did wrong here?

Saif Mirza
  • 63
  • 2
  • 9
  • you may be doing nothing wrong SPDY_ERROR is caused by different reasons beyond your front end code control check this https://stackoverflow.com/questions/33867014/what-does-err-spdy-protocol-error-mean-in-nginx – arpit sharma Mar 06 '19 at 11:13
  • Thanks @arpitsharma for reply, but i am unable to understand the answers provided in that link as i am new to Angular and don't have any Deployment Experience. Rightnow whatever i am developing is in my local machine and not on live server, hope you are getting my point. If you have any other suggestion please share with me. – Saif Mirza Mar 06 '19 at 11:22
  • test on IE or Firefox or safari – arpit sharma Mar 06 '19 at 11:30
  • @arpitsharma Problem is still same, even when i test on FireFox , IE and Edge. – Saif Mirza Mar 06 '19 at 11:58

0 Answers0