Я не уверен на 100%, в чем конкретно заключается ваша проблема, но позвольте мне помочь вам разобраться с этим.
async function someFunc() {
// Obviously this has to be inside of an async function if using await, so let's add it for clarity
let check_duplicate_phone = store.state.lines.map(function(item) {
return core.checkIsPhoneDuplicate(item.phone, item.phone_significant);
});
/*
So with this code, you won't get anything in res. You're awaiting the reuslt of
the promise, which is great, but the .then is going to be called first,
and you return nothing from it, so therefore, you won't get anything back
*/
//let res = await Promise.all(check_duplicate_phone).then(function(values) {
//console.log(values);
//});
// try this
let resolvedValues = await Promise.all(check_duplicate_phone); // Values in here
console.log(resolvedValues); // Or however you want to log them.
}
async function checkIsPhoneDuplicate(phone, phone_significant) {
var data = {
'phone': phone,
'phone_significant': phone_significant
}
/*
Again, here you are mixing async/await and .then, which is okay, but
Let's take full advantage of async/await to clean it up
*/
/*let res = await Axios.post(checkPhoneDuplicate_route, data)
.then(response => {
return response.data;
}).catch(error => console.log(error));*/
try {
let res = await Axious.post(checkPhoneDuplicate_route, data);
return res.data;
} catch (e) {
console.log(e);
}
}
Надеюсь, это немного поможет. Я думаю, что это сработает для вас или, по крайней мере, направит вас по правильному пути, когда код немного чище.