Сайт nuxt + strapi
Через postman запрос работает.
.env
API_URL=http://localhost:1337/api
nuxt.config.js
axios: {
// Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
baseURL: process.env.API_URL,
},
store/index.js
export const state = () => ({
option: null,
});
export const mutations = {
setOption(state, payload) {
state.option = payload;
},
};
export const actions = {
async nuxtServerInit({ dispatch }) {
await dispatch("storeDispatchFunc");
},
async storeDispatchFunc({ commit }) {
this.$axios
.get("/option")
.then((res) => {
console.log(res, "res");
commit("setOption", res);
})
.catch((error) => {
console.log(error, "error");
});
},
};
Почему в браузере option null?