I try to post data from angular 2 to php:
let headers = new Headers();
headers.append(\'Content-Type\', \'application/json\');
var order = {\'order\': this.o
I do not know if it's bad practice but it seems right to me, although it bothers me a little
const headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
const obj = { nome: 'gabriel', age: 20 };
const body = 'data=' + JSON.stringify(obj);
this.http.post('/test.php', body, { headers })
.subscribe(res => console.log(res.json()), res => console.error(res))
And in php
$post = json_decode($_POST['data']);