Skip to content

Latest commit

 

History

History
50 lines (34 loc) · 1.34 KB

config.md

File metadata and controls

50 lines (34 loc) · 1.34 KB

Configuration

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'
    }
  }

})

Note that for the root option to work, the path of the request must be relative. This will use this the root option: Vue.http.get('someUrl') while this will not: Vue.http.get('/someUrl').

Webpack/Browserify

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);

Legacy web servers

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;