显示undefined
。
如何让函数天气返回str值?(对不起我的英语不好)
function weather(urlin){
request.get(urlin,function(err,res,body){
after = JSON.parse(body);
weatherary = [];
weatherary[0] = String(after.records.locations[0].location[0].weatherElement[0].time[0].elementValue[0].value);
replyary = weatherary[0].split("。");
t = String(replyary[2].match(/\d+/g));
tempa = t.replace(',','~');
str = replyary[0] + '\n?' + replyary[1].match(/\d+/g) + '% ' + '?' + tempa;
});
return str;
};