Axios承诺混乱

时间:2018-05-13 07:39:40

标签: javascript promise axios

我很困惑如何继续获取Test1的所有其他信息索引的结果,所以如果Test1为true,即使Test2和Test3为null,它也将基于Test1继续打印

let info = ["Test1", "Test2", "Test3"];

isInfoAviable= (email) => {
    payload.info = info
    return axios.post(url, payload, axiosConfig).then((response) => {
        return response.data.isAvailable ? true : null
    }).catch((error) => {
        console.log(error);
    });
}

for (info of infos) {

    isInfoAviable(info).then((res) => {
        console.log(res) // If Test1 returns true, it'll  true even if Test2 is null, why?
    })
}

0 个答案:

没有答案