response.send
不起作用。我认为回调有问题吗?
console.log
什么也不打印。
请帮助!
const teamToIDs = {
"lakers": "1610612747",
"warriors": "1610612744",
"heat": "1610612748",
"suns": "1610612756"
}
app.get('/teams/:teamName', function(request, response){
urllib.request('http://data.nba.net/10s/prod/v1/2018/players.json', function (err, data) {
let teamName = request.params.teamName
const result = JSON.parse(data.toString())
teamToIDs = result.league.standard
console.log(data[teamName])
})
response.send(teamToIDs[teamName])
})