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.

Vue-Resource with Vue2.0 - Get Error

See original GitHub issue

Hi i’m using now Vue 2.0 with Vue-Resources, Bundler is Browserify.

I bind vue-resource in the app.js

// Adding Vue Plugins
Vue.use(VueResource)

// Vue App
new Vue({
  render: h => h(App)
}).$mount('#app')

Than i use it on a compontent method

methods: {
      fetchContent() {
        this.$http.get('https://content.json', {

        }).then(response => {
          console.log(response)
        }, response => {
          console.log('Fetch Failed')
        })
      }
    },

But i get Uncaught TypeError: Cannot read property 'get' of undefined

Is there a new secret to bind Plugins on the app.js file? The actual solution is, that i import vue, vue-resource in the component and Vue.use(VueResource). Than it works but i think that can be the right solution.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:14
  • Comments:20 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
guidoboumancommented, Oct 11, 2016

By the way, my mount is a bit different:

import Vue from 'vue';
import VueResource from 'vue-resource';
import App from './app';

Vue.use(VueResource);

/* eslint-disable no-new */
new Vue({
  el: '#app',
  render: h => h(App),
});

Would be a good bug if vue-resource doesn’t work when initialising before mount.

6reactions
gibexcommented, Oct 3, 2016

Same issue with webpack, no $http on this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue 2 and Vue-Resource [Cannot read property 'get' of ...
Vue1 this worked smoothly. What am I missing to get this working with Vue-2? Error: Uncaught TypeError: Cannot read property 'get' of undefined( ......
Read more >
Error Tracking and Handling with Vue.js - Rollbar
The Vue global error handler assigned above to the window.onerror property gets called on all uncaught errors and catches them across the entire ......
Read more >
Syntax error vueapp.js) IN I.E 11 vueJS don't work - Get Help
(Blank page) (SCRIPT1002: Syntax error vueapp.js) IN I.E 11 vueJS don't ... from "vue2-google-maps"; import VueResource from 'vue-resource'; ...
Read more >
Axios catch error not show - Laracasts
I'm following this lesson https://laracasts.com/series/learn-vue-2-step-by-step/episodes/19 Can you help me review my code and explain why it not work ?
Read more >
vue-axios - npm
import Vue from 'vue' // in Vue 2 import * as Vue from 'vue' // in Vue ... console.log(response.data) }) this.axios.get(api).then((response) ...
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