Skip to content
Advertisement

Problem with fetching data from Spring Boot API endpoint using Java Script

I work on web application and encountered an issue with fetching data from an endpoint using Java Script. If I type endpoint adres in a browser it works perfectly fine but somehow it does not work in the script. The response.ok is returns False.

Here is script:

JavaScript

Here is controller:

JavaScript

Here is service:

JavaScript

What is wrong? If You have any other advice regarding my work I will be pleased to hear it.

EDIT

The script and and HTML file which runs it are both located in static directory in classpath.

Advertisement

Answer

You should be doing it like this:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement