@shyann
To pass Laravel session to Vue.js, you can use the following steps:
1 2 3 |
Route::get('/session-data', function() { return session()->all(); }); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import axios from 'axios'; export default { data() { return { sessionData: {} }; }, mounted() { axios.get('/session-data') .then(response => { this.sessionData = response.data; }) .catch(error => { console.error(error); }); } }; |
1
|
<p>Session Data: {{ sessionData }}</p> |
By following these steps, you can easily pass Laravel session data to Vue.js and use it in your Vue components.