小编Ven*_*kat的帖子

在 localhost:4200 中找不到 404

我试图将数据从“ http://localhost:8082/api/kanchiwork/ ”传递到“ http://localhost:4200/ ”。我的 proxy.config.json 文件是:

    {
      "context": [
        "/api/**"
      ],
      "pathRewrite": {
        "^/api": ""
      },
      "ws": false,
      "target": "http://localhost:8082",
      "secure": false,
      "changeOrigin": true,
      "logLevel": "debug"
    }
  ]
Run Code Online (Sandbox Code Playgroud)

我的服务文件如下。

import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class PeopleService {

  constructor(private http:HttpClient) { }

  fetchPeople(): Observable<Object>{
    return this.http.get('/api/kanchiwork/');
    //return this.http.get('assets/response.json');
  };

}
Run Code Online (Sandbox Code Playgroud)

。当我尝试传递值时,我在控制台中收到消息“GET localhost:4200/api/kanchiwork 404 (Not Found)”。

api angular-cli angular

2
推荐指数
1
解决办法
9187
查看次数

标签 统计

angular ×1

angular-cli ×1

api ×1