Answer the question
In order to leave comments, you need to log in
Why does php post return empty after axios request?
Here is the data sent:
const requestBody = {
name: 'Akexorcist',
age: '28',
position: 'Android Developer',
description: 'desc',
awesome: true
}
const config = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}
axios.post('/js/mail.php', requestBody, config)
.then((response) => {
console.log(response.data)
})
.catch((err) => {
// Do somthing
})
<?php
$body = json_decode(file_get_contents("php://input"), TRUE);
print_r($body);
Answer the question
In order to leave comments, you need to log in
How is the "application/x-www-form-urlencoded" header related to json?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question