【Vue/Rails】Promiseを介すとRspecが通らない?
JWT認証のユーザー登録機能を
VueでhandleRegister
メソッドに
定義
axios → Promise → handleRegister
メソッド発火としたら
CapybaraでNetwork Error
の応酬
// auth.service.js class AuthService { register(user) { return axios.post(API_URL + 'users', { name: user.name, email: user.email, password: user.password, password_confirmation: user.password_confirmation }); } }
// auth.module.js actions: { register({ commit }, user) { return AuthService.register(user).then( response => { commit('registerSuccess'); return Promise.resolve(response.data); }, error => { commit('registerFailure'); return Promise.reject(error); } ); } },
// Register.vue methods: { handleRegister() { this.message = ''; this.submitted = true; this.$store.dispatch('auth/register', this.user).then( data => { this.message = data.message; this.successful = true; this.$router.push('/login'); }, error => { this.message = (error.response && error.response.data) || error.message || error.toString(); this.successful = false; } );
Promiseを通さず axiosのみの実装としたら 解消。
なにゆえ‥??