React Code:
const response = await fetch("../componentsunused/testingphp.php", {
headers: {
"Content-Type": "application/json" // request content type
}
});
console.log("myResponse:" JSON.stringify(response))
this.setState({ items: await response.json() });
PHP Code:
$arr = array('a' => "123");
echo json_encode($arr);
myResponse in console always comes out as an empty array. I checked and the request went through and was returned okay. What is wrong? Thank you very much for your help.
CodePudding user response: