When axios calls the same api, and so on many times at the same time, it executes the next step when all of them are returned correctly.

now encapsulates an api called postItemData () {}; when submitting data, the api, is called multiple times in submit () {} through items in an array as follows:

    postItemData(data){ 
        axios.post(data).then()
    },
    submit(array){
        array.forEach(item => {
            this.postItemData(item)
        })
    }

how can I execute the callback function after all requests are returned correctly? Feel that you should use axios.all, how to write the request? Thank you

Oct.25,2021

    postItemData(data){ 
        return axios.post(data)
    },
    submit:async function(array){
        await Promise.all(array.map(item => this.postItemData(item)));
        //
    }

promise.all


  https://zhuanlan.zhihu.com/p/.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3fbf0-2c4c0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3fbf0-2c4c0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?