如何从本地路由器js中的urllib.request中获取数据?

时间:2020-09-03 19:57:37

标签: javascript urllib

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])
    })

0 个答案:

没有答案