diff --git a/server/src/Service/JsonResponse.php b/server/src/Service/JsonResponse.php index 4079dc8..c7d32ec 100644 --- a/server/src/Service/JsonResponse.php +++ b/server/src/Service/JsonResponse.php @@ -4,13 +4,17 @@ namespace App\Service; class JsonResponse { - public function create(array $data, $code) + public function create(int $code, string $message = null, array $data = []) { - $response = json_encode($data); + $response = [ + 'code' => $code, + 'message' => $message, + 'data' => $data + ]; header('Content-Type: application/json'); http_response_code($code); - return $response; + return json_encode($response); } } \ No newline at end of file