POST request 400 Bad Request
Ich versuche einen POST request an die route /data zu schicken.
Das funktioniert in Postman aber nicht auf meiner Lokalen Seit
Ich habe die generierten Code von Postman genutzt für den fetch() Request.
DIE ROUTE :
PHP-Code:
*/
/**
* @Route("/data", defaults={"_scope": "frontend"})
*/
public function myroute1234(Request $request)
{
return new Response("OK");
}
DER JAVSCRIPT REQUEST:
HTML-Code:
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"db_id": "12",
"h1": "10",
"h2": "10",
"p": "10",
"button": "10",
"h1_mobile": "10",
"h2_mobile": "10",
"p_mobile": "10",
"button_mobile": "10"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("http://contao3.loc/data", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
FEHLERMELDUNG
PHP-Code:
POST http://contao3.loc/data 400 (Bad Request)
Kennt jemand das Problem ?