3👍
Axios is a simple promise based HTTP client. In Laravel, it is on the window object by default, so just use like so:
GET
axios.get('/some-path').then(res => {
console.log(res.data)
})
POST
let data = {
some: "thing"
}
axios.post('/some-path', data).then(res => {
console.log(res.data)
})
Documentation is pretty good, as always, RTFM.
EDIT 1
If you get undefined on the axios object, use
import axios from 'axios'
at the top of your JS file and if you are entirely missing Axios, npm install axios --save
👤ggdx
1👍
in your resource/assests/js/app.js
simple add:
var axios = require(‘axios’);
since
import axios from ‘axios’
– seems to be depricated
- [Vuejs]-Vue.js component inline style concatenation
- [Vuejs]-Is it possible to inject css into Vue component style section?
Source:stackexchange.com