vue js axios post example
Example 1: axios in vue
npm install axios
import axios from 'axios'
testMethod () {
axios.post('URL')
.then(function (response) {
alert (response.data);
})
.catch(function (error) {
alert(error);
});
}
Example 2: how to use axios in vue
npm install axios
import axios from 'axios'
test () {
axios.post('URL')
.then(function (response) {
alert (response.data);
})
.catch(function (error) {
alert(error);
});
}
Example 3: axios vuejs
axios
.get('https://api.coindesk.com/v1/bpi/currentprice.json')
.then(response => (this.info = response.data.bpi))
Example 4: axios post data vue js
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
router.post('/new/post', (req, res) => {
res.json(console.log("this is working" + ' ' + req.body.name));
});