Set default values using the global configuration.
Vue.http.options.root = '/root';
Vue.http.headers.common['Authorization'] = 'Basic YXBpOnBhc3N3b3Jk';
Set default values inside your Vue component options.
new Vue({
http: {
root: '/root',
headers: {
Authorization: 'Basic YXBpOnBhc3N3b3Jk'
}
}
})
Add vue
and vue-resource
to your package.json
, then npm install
, then add these lines in your code:
var Vue = require('vue');
var VueResource = require('vue-resource');
Vue.use(VueResource);
If your web server can't handle requests encoded as application/json
, you can enable the emulateJSON
option. This will send the request as application/x-www-form-urlencoded
MIME type, as if from an normal HTML form.
Vue.http.options.emulateJSON = true;
If your web server can't handle REST/HTTP requests like PUT
, PATCH
and DELETE
, you can enable the emulateHTTP
option. This will set the X-HTTP-Method-Override
header with the actual HTTP method and use a normal POST
request.
Vue.http.options.emulateHTTP = true;