export function postMethod(data) { const baseURL = process.env.BASE_API
axios({
method: 'post',
url: baseURL + '/img_upload',
timeout: 50000,
data: data,
headers: { 'loginToken': getLoginToken()
}
}).then(res => { const respose = res.data if (respose.errno == 'success') { //成功
//console.log(respose.data)
//******************此處返回((((((((((((((((
return respose.data //******************此處返回))))))))))))))))
} else if (respose.errno == 'fail') { //失敗
Message({
message: respose.msg, type: 'error',
duration: 2 * 1000
})
} else { //登錄失敗
Message({
message: '登錄失敗', type: 'error',
duration: 2 * 1000
})
}
})
}在別處使用postMethod(data)時,結(jié)果是undefined。這個return沒起作用,如何讓函數(shù)返回調(diào)取接口時返回的數(shù)據(jù)?
es6函數(shù)的.then中無法return結(jié)果
德瑪西亞99
2019-03-01 20:33:23