dasdsd
This commit is contained in:
@@ -8,6 +8,9 @@ use ModulesCore\ModuleHttp;
|
|||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
|
||||||
|
try {
|
||||||
ModuleHttp::requireDesktopAccess(dirname(__DIR__, 3), true);
|
ModuleHttp::requireDesktopAccess(dirname(__DIR__, 3), true);
|
||||||
require_auth();
|
require_auth();
|
||||||
|
|
||||||
@@ -16,7 +19,6 @@ $ownerSub = trim((string) ($user['sub'] ?? 'local'));
|
|||||||
|
|
||||||
$instrumentId = (int) ($_GET['instrument_id'] ?? 0);
|
$instrumentId = (int) ($_GET['instrument_id'] ?? 0);
|
||||||
if ($instrumentId <= 0) {
|
if ($instrumentId <= 0) {
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
|
||||||
echo json_encode(['ok' => false, 'message' => 'instrument_id fehlt.'], JSON_UNESCAPED_UNICODE);
|
echo json_encode(['ok' => false, 'message' => 'instrument_id fehlt.'], JSON_UNESCAPED_UNICODE);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@@ -40,7 +42,6 @@ $stmt->execute([
|
|||||||
]);
|
]);
|
||||||
$instrument = $stmt->fetch(PDO::FETCH_ASSOC);
|
$instrument = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
|
||||||
if (!is_array($instrument)) {
|
if (!is_array($instrument)) {
|
||||||
echo json_encode(['ok' => false, 'message' => 'Aktie nicht verfuegbar.'], JSON_UNESCAPED_UNICODE);
|
echo json_encode(['ok' => false, 'message' => 'Aktie nicht verfuegbar.'], JSON_UNESCAPED_UNICODE);
|
||||||
exit;
|
exit;
|
||||||
@@ -137,3 +138,12 @@ echo json_encode([
|
|||||||
'source_label' => 'Lokale Kurshistorie',
|
'source_label' => 'Lokale Kurshistorie',
|
||||||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
exit;
|
exit;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
echo json_encode([
|
||||||
|
'ok' => false,
|
||||||
|
'message' => 'Chartdaten konnten nicht geladen werden.',
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|||||||
@@ -119,7 +119,14 @@
|
|||||||
credentials: 'same-origin',
|
credentials: 'same-origin',
|
||||||
headers: { Accept: 'application/json' }
|
headers: { Accept: 'application/json' }
|
||||||
});
|
});
|
||||||
const payload = await response.json();
|
const responseText = await response.text();
|
||||||
|
let payload = null;
|
||||||
|
try {
|
||||||
|
payload = JSON.parse(responseText);
|
||||||
|
} catch (_error) {
|
||||||
|
const preview = responseText.trim().slice(0, 160);
|
||||||
|
throw new Error(preview !== '' ? `Chart-API liefert kein JSON: ${preview}` : 'Chart-API liefert kein JSON.');
|
||||||
|
}
|
||||||
if (!payload.ok) {
|
if (!payload.ok) {
|
||||||
throw new Error(payload.message || 'Chartdaten konnten nicht geladen werden.');
|
throw new Error(payload.message || 'Chartdaten konnten nicht geladen werden.');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user