I followed Angular 2's Tour of Hero tutorial with in memory database. Then I created a Spring backend to supply data and want to integrate Angular2 with Spring's Rest API.
In Tour of Hero I only changed one line of code in hero.service.ts:
/* private heroesUrl = 'app/heroes'; */
private heroesUrl = 'http://localhost:8080/api/hero/all';
The link I changed to is the the Spring service endpoint, if I type the link in browser, it returns JSON data: [{"id":1,"name":"test"}]
.
However, I am getting error in Tour of Hero:
EXCEPTION: Uncaught (in promise): Response with status: 404 Not Found for URL: null
It looks like the spring endpoint of localhost:8080
is not found by Angular application running on localhost:3000
. What could be the issue?
This was asked a while ago, but probably someone finds it useful.
Delete the following dependency from your package.json:
"angular-in-memory-web-api": "~0.2.4",
Remove it from node_modules
directory, delete all InMemoryWebApiModule
and InMemoryWebApiModule
and InMemoryDataService
-related code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With