pagekit / vue-resource

The HTTP client for Vue.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Http options don't work when included with Vue instance

websanova opened this issue · 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:

#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)
})

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