I try to return all the records from my database when I go to the browser I get this error.
SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 3 column 1 of the JSON data
I do not see an error in this record anywhere, or someone is able to help me solve this problem.
My code
<?php declare(strict_types=1);
header('Content-Type: application/json');
include_once("./controllers/database.php");
$sql = "SELECT * FROM `users`;";
$res = mysqli_query($conn, $sql);
$jsonData = array();
while ($array = mysqli_fetch_row($res)) {
$jsonData[] = $array;
}
echo json_encode($jsonData);
mysqli_close($conn);
?>