Angular 9 GET api Http失败响应404错误

问题描述 投票:0回答:1

我正在从UI调用REST API,但出现错误

错误代码:404消息:https://localhost:5001/api/SampleDataSource/GetDetails的Http错误响应:404 OK

query(): Observable < object > {
      private headers = new HttpHeaders(); 

     this.headers = this.headers.append('X-Requested-With', 'XMLHttpRequest');
      this.headers = this.headers.append('Content-Type', 'application/json');
      this.headers = this.headers.append('Accept', 'application/json');
      this.headers = this.headers.append('Access-Control-Allow-Headers', 'Content-Type');

     return this.http.get(this.BASE_URL, { headers: this.headers }).pipe(catchError(this.handleError));
}
asp.net-web-api2 angular9
1个回答
0
投票

404-是标准错误,找不到请求的资源。检查您的api URL,看起来您的URL错误(可能是拼写错误?)。另外,要验证网址,请检查Chrome中的“网络”标签以查看真实网址enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.