I'm trying to load the data from an api with axios through a store action, but the SSR don't wait the action finish.
There is any away to do it?
nuxtServerInit({ dispatch }) {
return dispatch('core/load');
}
//core actions
import { list as categoryList } from '../../services/category';
export default {
load({ commit }) {
return categoryList().then(categories => {
commit('setCategories', categories);
});
}
};
//category action
import apiHttp from './api';
export function list() {
return apiHttp.get('/categories').then(response => response.data);
}
//api
import * as axios from 'axios';
import { API_URL } from '../config';
export default axios.create({
baseURL: API_URL //http://localhost:3000/
});Thanks!
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c106">#c106</a>)</em></sub></div>