My Spring Boot application hosts REST services at the back-end with Angular on the front-end. I am making REST calls from the user interface.
Here is a snippet of my code:
$http.get(urls.USER_SERVICE_API)
.then(
function (response) {
console.log('Successfully fetched all users');
$localStorage.users = response.data;
deferred.resolve(response);
},
function (errResponse) {
console.error('Error while loading users');
deferred.reject(errResponse);
}
);
app.constant('urls', {
BASE: '<a class="vglnk" href="http://localhost:8081/SpringBootCRUDApp" rel="nofollow"><span>http</span><span>://</span><span>localhost</span><span>:</span><span>8081</span><span>/</span><span>SpringBootCRUDApp</span></a>',
USER_SERVICE_API : '<a class="vglnk" href="http://localhost:8081/SpringBootCRUDApp/api/user/" rel="nofollow"><span>http</span><span>://</span><span>localhost</span><span>:</span><span>8081</span><span>/</span><span>SpringBootCRUDApp</span><span>/</span><span>api</span><span>/</span><span>user</span><span>/</span></a>'
});
The error message in Google Chrome browser indicates:
angular.min.js:103 GET http://localhost:8081/SpringBootCRUDApp/%3Ca%20class=%22vglnk%22%20href=%22http://localhost:8080/SpringBootCRUDApp/api/user/%22%20rel=%22nofollow%22%3E%3Cspan%3Ehttp%3C/span%3E%3Cspan%3E://%3C/span%3E%3Cspan%3Elocalhost%3C/span%3E%3Cspan%3E:%3C/span%3E%3Cspan%3E8080%3C/span%3E%3Cspan%3E/%3C/span%3E%3Cspan%3ESpringBootCRUDApp%3C/span%3E%3Cspan%3E/%3C/span%3E%3Cspan%3Eapi%3C/span%3E%3Cspan%3E/%3C/span%3E%3Cspan%3Euser%3C/span%3E%3Cspan%3E/%3C/span%3E%3C/a%3E 404
https://i.sstatic.net/w6HDs.jpg
When I call the REST service using Postman, it works fine. However, I encounter an issue when making the same call from the UI. Please assist me in identifying what I might be doing wrong in the process of calling REST APIs from the UI.
The complete REST URL is ::
http://localhost:8081/SpringBootCRUDApp/api/user/
Your help is highly appreciated!