question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

this is undefined (this.$http.get) in vuex 2.0 actions

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Reactions:14
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

21reactions
liuhedongcommented, Oct 14, 2016

import Vue from ‘vue’; … Vue.http.get(…)…

is work!!!

11reactions
steffanscommented, Mar 5, 2017
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found