this is undefined (this.$http.get) in vuex 2.0 actions
See original GitHub issueI try to migrate my vue 1.0 to 2.0 and it is really hard…many undocumented changes 😦
So, here is another:
This is my actions.js
file
import Vue from 'vue';
import Resource from 'vue-resource';
Vue.use(Resource);
export fetchData({commit}, filter) {
// bla bla
this.$http.get(...)
};
I tried Vue.$http.get
or Vue.root.$http.get
but nothing works…
// Edit: Ok Vue.http.get
works, but why does this.$http.get
not more works?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:14
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Uncaught TypeError: Cannot read property 'get' of undefined
$http.get is from Vue Resource. Make sure you are pulling that in properly by adding vue-resource to your package.json , install it via...
Read more >Handle HTTP requests in a Laravel Vue.js app with Axios
In this tutorial, we'll build a working app with Laravel and Vue.js and see how we can handle our HTTP requests with the...
Read more >Actions | Vuex
Action handlers receive a context object which exposes the same set of methods/properties on the store instance, so you can call ...
Read more >vuex cannot read properties of undefined - You.com
I need to post some form data to a mockapi endpoint, using Axios and Vuex. I'm using Vue Cli v2, and Vuex 3....
Read more >Watch for Vuex State changes! - DEV Community
Imagine you might want to dispatch different actions for each component once this API calls succeed, how can you achieve that while you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
import Vue from ‘vue’; … Vue.http.get(…)…
is work!!!
See http://jsfiddle.net/rrd7k8hp/1/