I am trying to fetch some data using Axios call and modify the data element by removing the matching element using object.splice(index,1)
but at the end result, I get all the elements the splice is not working,
I guess it might be something related to 'async and await' problem but not sure how to solve it.
getBeltDevicesList({ commit, dispatch,rootState}) {
commit('common/SET_SCROLL_OVER_LOCK_STATE', false, {root: true });
commit('common/SET_PENDING_STATE', true, { root: true});
commit('SET_SELECTED_DEVICE_ID', null);
const queryParams = {
skip: 0,
take: rootState.common.itemsOnPage,
...rootState.common.searchOptions,
};
return DataApiService
.getDataElements(queryParams)
.then(data => {
data.forEach((dataElements, index, object) => {
//alert(JSON.stringify(data))
const { vId,typeId} = dataElements;
if (vId !== null || typeId == 2) {
// alert(typeId);//splice is not removing the elements
object.splice(index, 1);
}
});
commit('SET_LIST', data);
commit('common/SET_PENDING_STATE', false, {root: true});
getDataElementsAssigning(data);
setFormattedBootstrapDate(data);
const selecteddataElement = rootState.common.pageMode === 'table' || !data.length ? null : data[0];
dispatch('selectdataElement', selecteddataElement);
});
}
data = data.filter(...)