'Why is axios not sending the correct post data?
Why is PHP saying "undefined index request"? The json format looks completely correct to me.
let json = JSON.stringify(
{ request: "getUser" },
{ username: "test" }
);
const response = await axios.post('http://localhost/projects/serverFiles/index.php', json);
My PHP
<?php
ini_set("log_errors", 1);
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
echo print_r($_POST["request"]);
?>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
