async与await的用法
123456789101112131415161718
function test(){ return new Promise((resolve, reject) => { mysql.query(sql, (error, result, fields) => { if (error) { reject(error); } else { resolve([result, fields]); } }) });}async function exceTest() { return await test();}var data = await exceTest();
async的使用条件:必须是promise对象