Suika
JCHJava Community | Help. Code. Learn.
•Created by Suika on 2/18/2025 in #java-help
Spring Boot, JavaScript fetching Endpoint
Hi, my method getSeconds() is not invoked.
@PostMapping("/get-seconds")
public ResponseEntity<Integer> getSeconds(@RequestBody ModulUpdateRequest request) {
log.info("called get-seconds");
return ResponseEntity.ok(modulService.getSecondsForId(UUID.fromString(request.fachId())));
}
this is my fetch:
export async function getSeconds(fachId) {
try {
const csrfToken = getCsrfToken();
console.log("csrf=" + csrfToken)
const response = await fetch('/api/get-seconds', {
method: 'POST',
credentials: "include",
headers: {
'Content-Type': 'application/json',
'X-XSRF-TOKEN': csrfToken
},
body: JSON.stringify({ fachId })
});
console.log(response)
//if (!response.ok) {
// throw new Error(
HTTP error! Status: ${response.status});
//}
return await response.text();
} catch (error) {
//console.error('Fehler beim Abrufen der Sekunden:', error);
}
}
222 replies
JCHJava Community | Help. Code. Learn.
•Created by Suika on 1/20/2025 in #java-help
Spring Boot, Eureka Server shuts Service down

3 replies
JCHJava Community | Help. Code. Learn.
•Created by Suika on 10/18/2024 in #java-help
Pipe data in POST-Controller with dynamically created th:name's (Spring Web, Thymeleaf)

21 replies