Reputation: 33
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"
}
However, when I run this application, I get a 404 error as seen in the image below:
Upvotes: 0
Views: 688
Reputation: 1836
Looks like you are not sending api/profile/...
with your service, as your proxy reversing api
routes to backend server.
Upvotes: 2