dgrubelic / vue-authenticate

Simple Vue.js authentication library
1.43k stars 252 forks source link

how to replace Axios with another library? #207

Open gadelkareem opened 4 years ago

gadelkareem commented 4 years ago

I am using https://github.com/twg/devour to handle my JSON API requests. How to use it instead of Axios?

dgrubelic commented 4 years ago

Hi, unfortunately, this is very small and rather unknown library to be implemented. What I recommend to create wrapper plugin library that will handle sending requests in vue-authenticate. You can even create a plugin, for example vue-authenticate-devour and publish it and I'll be glad to support it officially.

gadelkareem commented 4 years ago

That's good to know. Is there an example of a wrapper plugin that I can use? I tried to play with the plugin factory method but could not get through.

dgrubelic commented 4 years ago

Unfortunately, no. You'll have to google that yourself. You can check out how I did it here: https://github.com/dgrubelic/vue-authenticate/blob/master/src/index.js#L10 any try to implement it yourself.

gadelkareem commented 4 years ago

I mean how to inject the $http into vue-authenticate before adding it to Vue plugins?

ajmas commented 2 years ago

In Vue2 could probably just do the following:

Vue.prototype.$http = axios.create();

If you replace axios with anything else, you'll just need to make sure the function calls are compatible with the way this package uses it.