📚 Improved backend codebase structure & documentation (#123) 🌟

This commit is contained in:
Till Tomczak
2025-06-20 12:26:29 +02:00
parent 286a70b01f
commit 59f5c543e3
24 changed files with 757 additions and 8 deletions

View File

@ -117,10 +117,22 @@
// Create request promise
const promise = fetch(url, requestOptions)
.then(response => {
.then(async response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
// Content-Type-Validation für JSON-Responses
const contentType = response.headers.get('content-type');
if (!contentType || !contentType.includes('application/json')) {
const text = await response.text();
// Prüfe auf HTML-Fehlerseiten
if (text.includes('<!DOCTYPE html>') || text.includes('<html')) {
throw new Error(`Server-Fehlerseite erhalten statt JSON-Response`);
}
throw new Error(`Unexpected content-type: ${contentType}`);
}
return response.json();
})
.then(data => {