I am learning Front End with Angular and Back End with Spring Boot right now and I am having issues when I try to fetch data from the Back End.
Angular Code:
ngOnInit() {
this.http.get('http://127.0.0.1:8081/products').toPromise().then((data) => {
console.log(data);
});
}
The Back End is working just fine, because I tried getting data with Postman and it works just fine.
Also copied the URL(http://127.0.0.1:8081/products) directly into my browser and it works just fine.
But when i try to request data from for example from JSONPlaceholder it works fine with the angular http get function.
ngOnInit() {
this.http.get('http://jsonplaceholder.typicode.com/todos/1').toPromise().then((data) => {
console.log(data);
});
}
result of the JSONPlaceholder request:
{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
}
I hope this extra information helps you to help me.
Last but not least the error message I get: