Skip to content

Commit 1d4ff9c

Browse files
committed
make response body with more complete information to get user data
1 parent 9d3edee commit 1d4ff9c

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

‎src/controllers/UsersController.php‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,26 @@ public function __construct() {
1212
public function getAllUser() {
1313
$result = $this->user->getAllUser();
1414

15+
http_response_code(200);
1516
header('Content-Type: application/json');
16-
echo json_encode($result);
17+
$response = [
18+
"status"=>"success",
19+
"message"=> "successfully get all user data from database",
20+
"data"=> $result
21+
];
22+
echo json_encode($response);
1723
}
1824

1925
public function getUserById($id) {
2026
$result = $this->user->getUserById($id);
2127

28+
http_response_code(200);
2229
header('Content-Type: application/json');
23-
echo json_encode($result);
30+
$response = [
31+
"status"=>"success",
32+
"message"=> "successfully get user data from database",
33+
"data"=> $result
34+
];
35+
echo json_encode($response);
2436
}
2537
}

0 commit comments

Comments
 (0)