diadal / vue-social-auth

Laravel Vue (SPA) Social Auth
75 stars 27 forks source link

How to use it without vue-axios #17

Closed kikky7 closed 4 years ago

kikky7 commented 4 years ago

It's said it isn't strictly coupled to vue-axios, but there is only an example with vue-axios. How to use this package without it? While trying to console log this.$auth always returns Error: Request handler instance not found, since it required vue-axios wrapper. I use axios library and I don't need a wrapper for it.

andreas83 commented 4 years ago

asking the same question...

diadal commented 4 years ago

you can remove vue-axios and use just axios then Vue.prototype. axios = axios or

Vue.use(VueAxios, axios)
Vue.use(VueSocialauth, {....})
VueSocialauth

make this.$auth available in all your code you can call anyway since you Vue.use(VueSocialauth, {....}) in mean.js or app.js

andreas83 commented 4 years ago

I removed vue-axios which breaked following suggessted line: Vue.use(VueAxios, axios) and i got following error: Error: Request handler instance not found

i assume the first statement should be something like

Vue.prototype.$http = axios

than i got rid of the "Request handler instance not found" issue but the request still can be processed: {err: Error: Request failed with status code 500}

diadal commented 4 years ago

how do you make your request share you code

andreas83 commented 4 years ago
        AuthProvider(provider, event) {
          event.preventDefault();
          var self = this

          this.$auth.authenticate(provider).then(response =>{

            self.SocialLogin(provider,response)
            }).catch(err => {
                console.log({err:err})
            })
        },
        SocialLogin(provider,response){
            axios.post('/api/auth/'+provider,response).then(response => {
                console.log(response.data)
            }).catch(err => {
                console.log({err:err})
            })
        }
diadal commented 4 years ago

this axios.post it should be this.axios.post

andreas83 commented 4 years ago

for some unknown reasons it works now for me, was maybe a caching issue...
thanks for help!!!

mvcexpert commented 4 years ago

I am getting "Uncaught TypeError: Cannot set property 'axios' of undefined"

I have installed all the packages installed, and my app already uses "axiox" for AJAX calls

if comment out //Vue.use(VueAxios, axios)

The error no longer occurs, then I get Error: Request handler instance not found

//Here is what I added to my login component ![Uploading Screen Shot 2020-10-09 at 4.53.50 PM.png…]()