Debug: paranna virhekäsittelyä todo_status + apiCall JSON parse

apiCall palauttaa nyt selkeän virheen jos palvelimen vastaus
ei ole validia JSON:ia (+ logittaa console.error). todo_status
palauttaa JSON-virheen myös edge-caseissa.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-11 13:52:50 +02:00
parent b0c9817aaa
commit e53a6babdb
2 changed files with 10 additions and 3 deletions

View File

@@ -2289,8 +2289,10 @@ switch ($action) {
case 'todo_status':
requireAuth();
$companyId = requireCompany();
if ($method !== 'POST') break;
$input = json_decode(file_get_contents('php://input'), true);
if ($method !== 'POST') { echo json_encode(['error' => 'POST required']); break; }
$rawInput = file_get_contents('php://input');
$input = json_decode($rawInput, true);
if (!$input) { echo json_encode(['error' => 'Invalid JSON input', 'raw' => substr($rawInput, 0, 200)]); break; }
$id = $input['id'] ?? '';
$status = $input['status'] ?? '';
$todo = dbLoadTodo($id);