geatistsimiokin
geatistsimiokin

Reputation: 33

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"
  }

However, when I run this application, I get a 404 error as seen in the image below:

enter image description here

enter image description here

Upvotes: 0

Views: 688

Answers (1)

Zhengzhe Li
Zhengzhe Li

Reputation: 1836

Looks like you are not sending api/profile/... with your service, as your proxy reversing api routes to backend server.

Upvotes: 2

Related Questions