groupsCall(callType, params) {
let url = `/....../`,
errorMessage = `could not load the items`;
url =
callType === "get" ? url + "selected_groups" : url + "update_groups";
axiosConfig[callType](url, params)
.then((response) => {
const data = response.data;
console.log("hittttt", data.groups_with_selected);
let tmp = data.groups_with_selected[1];
data.groups_with_selected[1] = data.groups_with_selected[6];
data.groups_with_selected[6] = tmp;
if (isObject(data)) {
this.setGroupsData(data);
this.getTotalCount();
errorMessage = "";
this.setUpdating(data);
}
this.errorMessage = errorMessage;
})
.catch((error) => {
errorMessage = `${errorMessage}. ${error}`;
this.errorMessage = errorMessage;
this.updating = false;
});
},
How to change array element position without swapping in Vuejs?
I have used below logic for swaping elements, Where with the below code. 6th position changed to 1st position. and 1st position swapped with 6th position.
let tmp = data.groups_with_selected[1];
data.groups_with_selected[1] = data.groups_with_selected[6];
data.groups_with_selected[6] = tmp;
But problem here is, I want to change array element position only. But without swapping. How can I proceed i am not sure, tried with many logic.