I'm really confused. I tried to lot of things but I can't reach the correct result.
Here is scenario; I have list of products that I can do multiple choice and delete them one by one. I want to wait all items can be deleted then return me a count.
async delete (ids) {
const res = await this.deleteProcess(ids);
return res;
},
deleteProcess(ids) {
let countS = 0;
Object.assign(ids).map((id) => {
axios({
method: "DELETE",
url: store.getters.getServerPath + "api/v1/product/" + id,
headers: store.getters.getConfigHeaders,
withCredentials: true
}).then(function (response) {
countS++;
}).then(() => {
console.log(countS);
return countS;
});
});
}
And call this function like this:
deleteSelected (id) {
if (id !== undefined) {
this.selectedRows.push(id);
}
controller.delete(this.selectedRows).then(function (res) {
alert(res + " items deleted");
});
},
Result res is always returns undefined. But inside of deleteProcess console.log is displayed how many items were deleted.