Xiaobai asked: how can Promise.all get the value in axios.then?

related codes

/ / Please paste the code text below (do not replace the code with pictures)

    var appid = "20180915000207344";
    var key = "Rnwm_ZdMug9nrE42ypSM";
    var salt = (new Date).getTime();
    var from = "en";
    var to = "zh";
    var query=_.map(country,function(item) {
        var str1 = appid + item.name + salt + key;
        var sign = MD5(str1);
        axios.get("http://api.fanyi.baidu.com/api/trans/vip/translate", {
                        params: {
                            q: item.name,
                            appid: appid,
                            salt: salt,
                            from: from,
                            to: to,
                            sign: sign
                        }
           }).then(function (res) {
                        var result= _.merge(item, {cn_name: res.data.trans_result[0].dst});
                        resolve(result);
                 
                    });
                });
        Promise.all(axios).then(function(result){
            console.log(result);
        }).catch(function(error){
            console.log(error);
        });

what result do you expect? What is the error message actually seen?

I hope promise.all can output result at once.
but the final output value is undefiend.
tried other spellings and finally returned pending status
didn"t axios.then return a promise object?
how should I write if I want to output correctly?

Jul.13,2021

let p = new Promise((r,j)=>{
    asios.get(...).then((x)=>{
        ...//x
        r(x)
    }).catch((e)=>{
        j(e)
    })
})
Promise.all([p]).then((res)=>{
    res[0]//then 
})

pseudo code to help understand


try return axios.get. and Promise.all (query)

Menu