Answer the question
In order to leave comments, you need to log in
How to pass async id received from request?
How to get value by id key if it returns empty when directly loading site mysite.com/test-slova but go to home and click on route it will not output empty but output id key value
Actions.js: https:// paste.laravel.io/41d0a3ef-ef22-46cf-9418-4...
Getters.js: https://paste.laravel.io/c2244956-5d61-4af3-b171-f...
CategoryCurrent.vue: https: //paste.laravel.io/81cccc25-3606-4cf4-9851-0...
Assigned aync and await, I think it's not true since it does not wait until the first request is loaded.
Answer the question
In order to leave comments, you need to log in
Ashkn is written incorrectly, or you use async/await or promise.then.
a case of you
async categoryBySlug ({commit}, slug) {
commit(CATEGORY_BY_SLUG)
const response = await axios.get(`${API_BASE}/categories`, {
params: {
slug: slug
}
})
commit(CATEGORY_BY_SLUG_SUCCESS, response.data.data)
},
async allProductsById ({commit}, id) {
commit(ALL_PRODUCTS_BY_ID);
const response = await axios.get(`${API_BASE}/products`, {
params: {
category_id: id
}
})
commit(ALL_PRODUCTS_BY_ID_SUCCESS, response.data.data)
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question