N
N
Nikolay Semenov2017-08-12 07:47:01
JavaScript
Nikolay Semenov, 2017-08-12 07:47:01

How to make axios work?

Hello!
I'm trying to include axsios in vue.
connection string
import axios from 'axios'
new instance property
Vue.prototype.$http = axios
in components request: works, but there is no file code
this.$http.get(bla bla bla)
in the js file located in the folder

import Vue from 'vue'

export default {
  getContacts (fn) {
    console.log(Vue.http)
    Vue.http.get('http://demo.fdlfk.com/users')
    debugger
      // .then(data => {
      //   if (data) {
      //     fn(data)
      //   }
      // })
  }
}

vue.http = undefined
help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
monochromer, 2017-08-12
@nickola105

Vue.prototype.$http = axios;

export default {
  getContacts (fn) {
    this.$http.get('http://demo.fdlfk.com/users')
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question