vue-resource icon indicating copy to clipboard operation
vue-resource copied to clipboard

Http options don't work when included with Vue instance

Open websanova opened this issue 6 years ago • 1 comments

I'm having issue with options.

When using Vue.http.options.root it's all good, when including with Vue instance it seems to be ignored.

Same as issue here:

https://github.com/pagekit/vue-resource/issues/487

Not sure why that was closed.

import Vue from 'vue'
import App from 'PAGES/Index.vue'

import http from './http'
import store from './store'
import router from './router'

import './config/icons.js'
import './config/plugins.js'
import './config/components.js'

Vue.config.productionTip = false

// Vue.http.options.root = 'https://testing123.com';

new Vue({
    el: '#app',
    http: {
        root: 'https://testing123.com'
    },
    store: store,
    router: router,
    render: h => h(App)
})

websanova avatar Jan 14 '19 10:01 websanova

This is broken for me as well. However I was able to monkey patch it by adding this mixin to my root component:

  Vue.mixin({
    beforeCreate() {
      if (!this.$options.http) {
        this.$options.http = this.$root.$options.http;
      }
    }
  });

I'm using:

  • vue: 2.6.7
  • vue-resource: 1.5.1

Edit: simplifying mixin patch

scottescue avatar Mar 11 '19 20:03 scottescue