function requestOrderAPI(name,floor){ let re = ''; let url = 'http://此處省略/reservations/plus1?name=' + qs.escape(name) +'&location='+floor; http.get(url,(res)=>{ res.setEncoding('utf8'); let rawData = ''; res.on('data', (chunk) => rawData += chunk); res.on('end', () => { re = rawData; }); }); return name + ':' + re;//異步的原因拿不到re的值}我想讓requestOrderAPI(name,floor)這個函數(shù)返回re。有什么好的辦法嗎?應(yīng)該怎么做哪?
Node.js http.get的返回結(jié)果,怎么傳到外面?
UYOU
2018-09-14 10:09:34