我正在node.js中为MongoDB数据库构建一个API,并使用fetch函数查询外部API,但是当代码运行时,fetch函数返回以下内容:promise{
我需要做什么才能返回请求的数据?
null
let requisicaoGetSummoner = function(summonerName) {
let summonerGet = fetch('https://br1.api.riotgames.com/lol/summoner/v4/summoners/by-name/' + summonerName + '?api_key=' + api_key)
.then(response => response.json())
.then(data => {
return data
})
.catch(err => console.log(err));
return summonerGet
}
null
返回提取。
let requisicaoGetSummoner = function(summonerName){
return fetch('https://br1.api.riotgames.com/lol/summoner/v4/summoners/by-name/' + summonerName + '?api_key=' + api_key)
.then(response => response.json())
.then(data => {
return data
})
.catch(err => console.log(err));
}