Skip to content

Commit

Permalink
switch vue-router to axios
Browse files Browse the repository at this point in the history
  • Loading branch information
verwilst committed Mar 5, 2017
1 parent 995da06 commit 635ac9a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"webpack": "^2.2.1"
},
"dependencies": {
"vue-router": "^2.3.0",
"vue-resource": "^1.0.3"
"vue-router": "^2.3.0"
}
}
5 changes: 1 addition & 4 deletions resources/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ require('./bootstrap');
import VueRouter from 'vue-router';
Vue.use(VueRouter);

var VueResource = require('vue-resource');
Vue.use(VueResource);

Vue.http.options.root = '/api'
axios.defaults.baseURL = '/api';

const routes = [
{ path: '/', component: FirstPage },
Expand Down
20 changes: 10 additions & 10 deletions resources/assets/js/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

window._ = require('lodash');

/**
Expand All @@ -8,6 +7,7 @@ window._ = require('lodash');
*/

window.$ = window.jQuery = require('jquery');

require('bootstrap-sass');

/**
Expand All @@ -17,19 +17,19 @@ require('bootstrap-sass');
*/

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

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

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

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

/**
* Echo exposes an expressive API for subscribing to channels and listening
Expand All @@ -42,4 +42,4 @@ Vue.http.interceptors.push((request, next) => {
// window.Echo = new Echo({
// broadcaster: 'pusher',
// key: 'your-pusher-key'
// });
// });
2 changes: 1 addition & 1 deletion resources/assets/js/pages/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
text-align: left;
color: #2c3e50;
margin-top: 60px;
}
Expand Down

0 comments on commit 635ac9a

Please sign in to comment.