}); $app->post('/feedback', 'checkToken', function () use($app) { $db = new dbHandler(); $token = $app->request->headers->get('token'); $message = $app->request->post('message'); if ($db->sendFeedback($token, $message)) { sendResponse(201, initBody(false, null), null); } else { sendResponse(400, initBody(true, "An error occurred."), null); } }); /*EVENT*/ $app->get('/events/:id', function ($id) use($app) { $db = new dbHandler(); if ($event = $db->getEvent($id)) { if (($user = $db->getEventUser($id)) && ($participants = $db->getEventParticipants($id))) { $event = $event->fetch_array(MYSQLI_ASSOC); $event['user'] = $user->fetch_array(MYSQLI_ASSOC); $array_participants = array(); while ($participant = $participants->fetch_assoc()) { array_push($array_participants, $participant); } $event['participants'] = $array_participants; sendResponse(200, initBody(false, ""), $event); } else { sendResponse(400, initBody(true, "An error occurred."), null); } } else { sendResponse(400, initBody(true, "An error occurred."), null); } });