0

I'm trying to login user. When I send correct data

Vue.axios.post(context.state.userAuthLinks.login, {
     email: playload.email,
     password: playload.password
})

it works fine, but when I try to post wrong data, vue app reload with

http://localhost:8080/?email=asd%40gmail.com&password=asdasdasd#/

also, I found stange thing. When I, for example, sing up new user with the same email, to get error, app does not reload... It happens not only with dev server. On product server the same error.

full method

loginUser(context, playload) {
    return new Promise((loginResolve, loginReject) => {
        Vue.axios.post(context.state.userAuthLinks.login, {
            email: playload.email,
            password: playload.password
        }).then(function(res) {
            loginResolve(res);
            context.commit('setUserId', res.data.userId);
            context.commit('setUserToken', res.data.id);
            context.commit('setUserAuthenticated', true);
        }).catch(function(error) {
            // here it don't stops with 'debugger'
            console.log(error);
            loginReject(error);
        });
    });
},

Also, I have theese headers

 Vue.axios.defaults.baseURL = 'http://localhost:3000';
 Vue.axios.defaults.headers.common['Content-Type'] = 'application/x-www-form-urlencoded';
Triple -B
  • 261
  • 2
  • 12
  • for example, I have User in data base asd@gmail.com and password "asd", When I send asd@gmail.com and password "asdasd" – Triple -B Aug 28 '17 at 17:59
  • The issue is probably in your backend, sending a redirect when the data doesn't match. AJAX requests follow redirects https://stackoverflow.com/questions/282429/returning-redirect-as-response-to-xhr-request/2573589#2573589 – yuriy636 Aug 28 '17 at 18:09
  • but when i use JQuery.ajax it does not happens, also Angularjs $http does not redirect – Triple -B Aug 28 '17 at 18:12

0 Answers0