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?