Answer the question
In order to leave comments, you need to log in
How to download the initial values of variables from the server using Vuex?
There is a store.js file for connecting the storage, in which you need to load data from a third-party server into the company variable via Axios. You need to do this at the start of the application.
export default new Vuex.Store({
state: {
company: [],
}
})
Answer the question
In order to leave comments, you need to log in
as an option in main.js in the beforeCreate hook, perform the initialization of filling the store
new Vue({
el: "#app",
router,
store,
beforeCreate() {
this.$http
.jsonp(getURL(method, { offset: 1, album_id: 0, extended: 1 }))
.then(response => {
return response.json();
})
.then(data => {
return data.response.items.map(items => {
///
return items;
});
})
.then(data => {
this.$store.dispatch("getData", data);
});
{
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question