Categories
Uncategorized Vue Answers

How to watch store values from Vuex with Vue.js?

Sometimes, we want to watch store values from Vuex with Vue.js.

In this article, we’ll look at how to watch store values from Vuex with Vue.js.

How to watch store values from Vuex with Vue.js?

To watch store values from Vuex with Vue.js, we get the value from a getter.

For instance, we write

<script>
import { mapGetters } from "vuex";

export default {
  computed: {
    ...mapGetters(["myState"]),
  },
  watch: {
    myState(val, oldVal) {
      console.log(val, oldVal);
    },
  },
};
</script>

to call mapGetters to map the myState getter to the myState computed property.

Then we add a watcher for myState and get the current value with val and the previous value with oldVal.

Conclusion

To watch store values from Vuex with Vue.js, we get the value from a getter.

Categories
Uncategorized

How to post image data using Postman?

Sometimes, we want to post image data using Postman.

In this article, we’ll look at how to post image data using Postman.

How to post image data using Postman?

To post image data using Postman, we can select form-data as the payload type.

Next, we enter the key for the form data entry in the key column.

Then we select the file in the value column.

Conclusion

To post image data using Postman, we can select form-data as the payload type.

Categories
Uncategorized

How to temporarily disable a foreign key constraint in MySQL?

To temporarily disable a foreign key constraint in MySQL, we set the FOREIGN_KEY_CHECKS environment variable.

To disable it, we run

SET FOREIGN_KEY_CHECKS=0;

to set FOREIGN_KEY_CHECKS to 0.

And then we enable it again by running

SET FOREIGN_KEY_CHECKS=1;