marfino3028
1 month ago
162
2
Vue

Error Cannot read property 'name' of undefined

Posted 1 month ago by marfino3028

Register.vue html

<vs-input
                  v-validate="'required|name|min:3'"
                  data-vv-validate-on="blur"
                  label-placeholder="Name"
                  name="name"
                  placeholder="Name"
                  v-model="name"
                  icon-pack="feather"
                  icon="icon-user"
                  class="w-full"
                />
                <span class="text-danger text-sm">{{
                  errors.first('name')
                }}</span>
              </div>

Register.vue js

export default {
data () {
 return {
  name: 'ujicoba',
  email: '@gmail.com',
  password: '12345678',
  confirm_password: '12345678',
  //coupon: '',
  isTermsConditionAccepted: false
}
},
computed: {
validateForm () {
  return (
    !this.errors.any() && this.name !== '' && this.email !== '' && this.password !== '' && this.confirm_password 
  !== '' && this.isTermsConditionAccepted === true
  )
}
},
methods: {
checkLogin () {
  if (this.$store.state.auth.isUserLoggedIn()) {
    this.$vs.notify({
      title: 'Login Attempt',
      text: 'You are already logged in!',
      iconPack: 'feather',
      icon: 'icon-alert-circle',
      color: 'warning'
    })
    return false
  }
  return true
},
register () {
  // If form is not validated or user is already login return
  if (!this.validateForm || !this.checkLogin()) return
  //this.$vs.loading()
  const payload = {
    
    userDetails: {
      name: this.name,
      email: this.email,
      password: this.password//,
      //confirmPassword: this.confirm_password
    },
    notify: this.$vs.notify
  }
  this.$store.dispatch('auth/register', payload)
    .then(() => { this.$vs.loading.close() })
    .catch(error => {
      this.$vs.loading.close()
      this.$vs.notify({
        title: 'Error',
        text: error.message,
        iconPack: 'feather',
        icon: 'icon-alert-circle',
        color: 'danger'
      })
    })
}

} }

Please sign in or create an account to participate in this conversation.