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

how to replace Axios with another library?

Open gadelkareem opened this issue 5 years ago • 5 comments

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

gadelkareem avatar May 02 '20 13:05 gadelkareem

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.

dgrubelic avatar May 02 '20 13:05 dgrubelic

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.

gadelkareem avatar May 02 '20 14:05 gadelkareem

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.

dgrubelic avatar May 02 '20 14:05 dgrubelic

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

gadelkareem avatar May 02 '20 14:05 gadelkareem

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.

ajmas avatar Dec 09 '21 04:12 ajmas