title: How to pass data from Vuejs to vuex Store?
body: <p>I have a vuejs component and a vuex store. </p>
  
  <p>I would like to send data from vue component to vuejs store and then call a function in vuex that's push data to a db.</p>
  
  <p>I get the data from currentUser (that works), but in vuex store I get the error: <code>Cannot read property 'push' of null</code>.</p>
  
  <p>I run <code>createPost</code> that works but the data does not pushed to vuex store I think because the error above. </p>
  
  <pre><code>#vuejs component
  import { mapState, mapGetters, mapMutations, mapActions } from "vuex";
  import {
    SET_NEWPOST,
    ADD_TAGS,
    SET_USERDATA,
    SET_GENERAL
  } from "@/store/posts/mutations";
  
  methods: {
    ...mapMutations("posts", {
      updateInformation: SET_NEWPOST,
      setUserData: SET_USERDATA,
      addGeneral: SET_GENERAL,
      addTags: ADD_TAGS
    }),
  
    ...mapActions("posts", {
      create: "triggerAddProductAction"
    }),
  
    async createPost() {
        this.updateInformation({
          content: this.content,
          url: this.newOne
        });
        this.updateUserData();
  
        this.createOne();
  
    }
  }
  </code></pre>
  
  <p>vuex  store</p>
  
  <pre><code>...
  const state = {
    products: []
  }    
  
  const mutations = {
     [addProduct]: (state, product) =&gt; state.products.push(product)
  },
  
  const actions: {
    createUserProduct: async ({ commit, rootState }, product) =&gt; {
      const userProductDb = new UserProductsDB(
          rootState.authentication.user.id
      );
  
      const createdProduct = await userProductDb.create(product);
      commit("addProduct", createdProduct);
   },
   triggerAddProductAction: ({ dispatch, state, commit }) =&gt; {
      const post = state.newPost;
      dispatch("createUserProduct", post);
   }
  }
  </code></pre>