GET http://localhost:4200/profile/1 404(未找到)
GET http://localhost:4200/profile/1 404 (Not Found)
profile.service.ts
getProfile(userId:number): Observable<UserModel> {
return this.httpClient.get<UserModel>('/profile/inquireUserInfo/' + userId);
}
profile.component.ts
private getProfile() {
this.profileService.getProfile(this.userId).subscribe(data => {
this.userModel = data;
}, error => {
console.log(error);
});
}
proxy.config.json
{
"/api/*": {
"target": "http://localhost:8080",
"secure": false,
"logLevel": "debug"
}
}
package.json
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.config.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
}
但是,当我 运行 这个应用程序时,我收到 404 错误,如下图所示:
您的服务似乎没有发送 api/profile/...
,因为您的代理反向 api
到后端服务器的路由。
profile.service.ts
getProfile(userId:number): Observable<UserModel> {
return this.httpClient.get<UserModel>('/profile/inquireUserInfo/' + userId);
}
profile.component.ts
private getProfile() {
this.profileService.getProfile(this.userId).subscribe(data => {
this.userModel = data;
}, error => {
console.log(error);
});
}
proxy.config.json
{
"/api/*": {
"target": "http://localhost:8080",
"secure": false,
"logLevel": "debug"
}
}
package.json
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.config.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
}
但是,当我 运行 这个应用程序时,我收到 404 错误,如下图所示:
您的服务似乎没有发送 api/profile/...
,因为您的代理反向 api
到后端服务器的路由。