tralasciando un attimo le richieste inviate con axios, sto facendo delle prove con postman.
questo l'header della richiesta:
codice:
POST /api/book/add.php HTTP/1.1
Host: www.sito.com
Content-Type: application/json
User-Agent: PostmanRuntime/7.19.0
Accept: */*
Cache-Control: no-cache
Postman-Token: 55d32547-2556-4477-9eca-c8e6cf6f61c3,9c351863-08df-4e7c-a561-fad3e6342511
Host: www.mattepuffo.com
Accept-Encoding: gzip, deflate
Content-Length: 51
Connection: keep-alive
cache-control: no-cache
{
"title": "ciao",
"author": 101,
"editor": 53
}
questo il codice PHP:
codice:
header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: Content-Type");
header("Content-Type: application/json");
$data = json_decode(file_get_contents("php://input"));
var_dump($data);
questa la risposta che vedo su postman:
codice:
object(stdClass)#1 (3) {
[
"title"
]=>
string(4) "ciao"
[
"author"
]=>
int(101)
[
"editor"
]=>
int(53)
}
quello che non capisco è come faccio ad elaborare i dati in PHP.