K
K
Konstantin2019-06-17 20:37:31
Vue.js
Konstantin, 2019-06-17 20:37:31

Why didn't the API connect to VUE js?

Tell me, I watched the video on the API in VUE js and completed the first step to connect.
https://www.youtube.com/watch?v=YZEm4dTnP80 (not advertising)
- installed the plugin as in the video
- added the code (maybe I entered it in the wrong place, in the wrong brackets?) The
error
5d07cf4307ae8402439560.png
code was:

import Vue from 'vue'
import './plugins/vuetify'
import App from './App.vue'
import router from './router'
import store from './store'
import Vuetify from 'vuetify/lib'
import 'vuetify/dist/vuetify.min.css'



Vue.use(Vuetify)



Vue.config.productionTip = false

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

After watching the video I did this:
import Vue from 'vue'
import './plugins/vuetify'
import App from './App.vue'
import router from './router'
import store from './store'
import Vuetify from 'vuetify/lib'
import 'vuetify/dist/vuetify.min.css'
var VueResource = require('vue-resource')



Vue.use(Vuetify)
Vue.use(VueResource)



Vue.config.productionTip = false

new Vue({
  router,
  store,

  render: h => h(App),

data: {
  endpoint: 'https://jsonplaceholder.typicode.com/posts'
}, 

methods: {
  gatAllPosts: function () {
     this.$http.get(this.endpoint).then(function(response) {
console.log(response)
     }, function (error) { 
       //ошибка 
    })
  }
},

created: function() { this.get.AllPosts
 }

  
})

.$mount('#app')

The question is how to solve the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-06-17
@gradk

gatAllPosts: function () {

this.get.AllPosts

Cool.
how to solve the problem?

Wipe your eyes. Twice they wrote the name of the method - they were sealed twice. Aren't you ashamed to come here with such nonsense?
Well, that's the thing, methods - they are called. Where are the parentheses after getAllPosts in created?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question