pagekit / vue-resource

The HTTP client for Vue.js
MIT License
10.08k stars 1.6k forks source link

Setting root does not take effect #741

Open noecs opened 4 years ago

noecs commented 4 years ago

I use the following code, root does not take effect.

I noticed the description in the documentation. For root to take effect, you must use a relative path. However, I used a relative path, and it could not normally request my designated server address. I tried to make a minimal example, it can reproduce my problem. https://github.com/noecs/vuetest

noecs commented 4 years ago

Supplementary explanation:

main.js

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

import VueResource from 'vue-resource';

Vue.use(VueResource);

Vue.config.productionTip = false;

new Vue({
  http: {
    root: 'http://google.com'
  },
  render: h => h(App),
}).$mount('#app');

App.vue

<template>
  <div id="app">
    F12 for test
    <button v-on:click="onLoad">click me</button>
  </div>
</template>

<script>

export default {
  name: 'App',
  methods: {
    onLoad: function () {
      this.$http.get('test');
    }
  }
}
</script>
IanTaite commented 4 years ago

Setting Vue.http.options.root = 'http://google.com'; does not seem to work either

noecs commented 4 years ago

I checked most of the issues. This is always a problem. This package does not seem to be maintained and updated. I will use other packages as an alternative. @IanT8

IanTaite commented 4 years ago

Do you intend to use axios instead? I hit this problem doing Max Schwarzmueller's Vue.js course on Udemy.

On Mon, 13 Apr 2020 at 20:19, noecs notifications@github.com wrote:

I checked most of the issues. This is always a problem. This package does not seem to be maintained and updated. I will use other packages as an alternative. @IanT8 https://github.com/IanT8

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pagekit/vue-resource/issues/741#issuecomment-612842185, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMYL73QZ424L25Z2MJOKD3RMLRLDANCNFSM4MGYNL4Q .

noecs commented 4 years ago

Yes, I think I will encapsulate an axios that I use. Although it is not elegant and independent of vue, it should be very effective.

noecs commented 4 years ago

@IanT8 I didn't understand the links you provided. Unable to open the link.