Answer the question
In order to leave comments, you need to log in
Why is there an error in the async function?
Hello.
I set up vue cli + ssr
Everything seemed to be fine, but for some reason the async / await function does not work.
Sample code below
// начинается все с axios
import axios from 'axios';
export default () => {
return axios.create({
baseURL: '',
headers: {'X-Requested-With': 'XMLHttpRequest'}
})
}
//тут запрос для тестов
import Api from './index';
export default {
getInfo () {
return Api.get('https://api.coindesk.com/v1/bpi/currentprice.json')
}
}
//тут store, все операции с апи
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex);
import Api from "../API/default"
export function createStore () {
return new Vuex.Store({
state: {
items: {
}
},
actions: {
async getItems({commit}) {
const RES = await Api.getInfo();
commit('updateItems', RES.data)
}
},
mutations: {
updateItems: (state, val) =>
state.items = val
}
})
}
TypeError: _index__WEBPACK_IMPORTED_MODULE_0__.default.get is not a function
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question