axios post params code example
Example 1: send axios request to php
<?php
$rp = json_decode(file_get_contents('php://input'), true);
Example 2: axios pass params
const axios = require('axios');
const res = await axios.get('https://httpbin.org/get', { params: { answer: 42 } });
res.data.args;
Example 3: axios post
axios.post('/user', {
firstName: 'Fred',
lastName: 'Flintstone'
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
Example 4: how to send data in query param in axios in get request
const res = await axios.get('https://httpbin.org/get', { params: { answer: 42 } });
Example 5: include axios
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
Example 6: axios post php
axios.post(url, JSON.stringify({
name: "this.name",
email: "this.psswrd"
}))
$_POST = json_decode(array_keys($_POST)[0], true);