[Vuejs]-Laravel vue getting info by hidden field

0👍

This happens because user_id in this.$data.project dosn’t get updated.

Instead of having hidden input you can just do

add() {
   this.errors = null;
   const errors = validate(Object.assign(this.$data.project, {user_id: this.currentUser.id}));
   if(errors) {
      this.errors = errors;
      return;
   }
   axios.post('/api/projects/new', Object.assign(this.$data.project, {user_id: this.currentUser.id}))
     .then((response) => {
         this.$router.push('/projects');
      });
}

Leave a comment