Skip to content

Commit 635ac9a

Browse files
committed
switch vue-router to axios
1 parent 995da06 commit 635ac9a

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"webpack": "^2.2.1"
2626
},
2727
"dependencies": {
28-
"vue-router": "^2.3.0",
29-
"vue-resource": "^1.0.3"
28+
"vue-router": "^2.3.0"
3029
}
3130
}

resources/assets/js/app.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ require('./bootstrap');
1919
import VueRouter from 'vue-router';
2020
Vue.use(VueRouter);
2121

22-
var VueResource = require('vue-resource');
23-
Vue.use(VueResource);
24-
25-
Vue.http.options.root = '/api'
22+
axios.defaults.baseURL = '/api';
2623

2724
const routes = [
2825
{ path: '/', component: FirstPage },

resources/assets/js/bootstrap.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
window._ = require('lodash');
32

43
/**
@@ -8,6 +7,7 @@ window._ = require('lodash');
87
*/
98

109
window.$ = window.jQuery = require('jquery');
10+
1111
require('bootstrap-sass');
1212

1313
/**
@@ -17,19 +17,19 @@ require('bootstrap-sass');
1717
*/
1818

1919
window.Vue = require('vue');
20-
require('vue-resource');
2120

2221
/**
23-
* We'll register a HTTP interceptor to attach the "CSRF" header to each of
24-
* the outgoing requests issued by this application. The CSRF middleware
25-
* included with Laravel will automatically verify the header's value.
22+
* We'll load the axios HTTP library which allows us to easily issue requests
23+
* to our Laravel back-end. This library automatically handles sending the
24+
* CSRF token as a header based on the value of the "XSRF" token cookie.
2625
*/
2726

28-
Vue.http.interceptors.push((request, next) => {
29-
request.headers.set('X-CSRF-TOKEN', Laravel.csrfToken);
27+
window.axios = require('axios');
3028

31-
next();
32-
});
29+
window.axios.defaults.headers.common = {
30+
'X-CSRF-TOKEN': window.Laravel.csrfToken,
31+
'X-Requested-With': 'XMLHttpRequest'
32+
};
3333

3434
/**
3535
* Echo exposes an expressive API for subscribing to channels and listening
@@ -42,4 +42,4 @@ Vue.http.interceptors.push((request, next) => {
4242
// window.Echo = new Echo({
4343
// broadcaster: 'pusher',
4444
// key: 'your-pusher-key'
45-
// });
45+
// });

resources/assets/js/pages/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
font-family: 'Avenir', Helvetica, Arial, sans-serif;
4040
-webkit-font-smoothing: antialiased;
4141
-moz-osx-font-smoothing: grayscale;
42-
text-align: center;
42+
text-align: left;
4343
color: #2c3e50;
4444
margin-top: 60px;
4545
}

0 commit comments

Comments
 (0)