1

enter image description hereI am getting an error when running my Angular 4 application written with Typescript, HTML, and CSS.

The error reads: GET http://localhost:4200/typeahead-component (404) NOT FOUND

This is my related code:

  public url: string = "typeahead-component/";

  return this.http
      .get(this.url)
      .subscribe(
          response => {
              console.log(response);
          },
          (err: HttpErrorResponse) => {
              if (err.error instanceof Error) {
                  console.log('An error occurred:', err.error.message);
              } else {
                  console.log("entering http get request.");
                  console.log(this.url);
                  console.log(err);
              }
          }

I am connecting my Angular 4 front-end to Spring Boot REST API back-end code. This is the relevant code in the back-end:

@GetMapping("typeahead-component/")
public List<String> get() {
    System.out.println("Entering getApps call.");
    return getApps.get();
}

I am trying to get a list of applications from the server via the server webpage's HTML.

I have seen this similar Stack Overflow post Angular 2 HTTP GET 404 Not Found for URL but my issue is not related to in-memory-web-api.

I have also seen this post Angular 2: 404 error occur when I refresh through the browser but was not able to solve the issue.

Any help would be greatly appreciated! Thank you!

Meena Mana
  • 249
  • 1
  • 7
  • 18

0 Answers0