尝试通过 request-promise 发出请求,但无法正常工作。
请参阅下面的评论。
有人可以向我解释这个 PiA 吗?
提前致谢
var todayOptions = { uri: `http://mlb.mlb.com/gdcross/components/game/mlb/year_${year}/month_${month}/day_${day}/master_scoreboard.json`,
simple: false,
resolveWithFullResponse: true
};
rp(todayOptions)
.then(function (response){
console.log(response.body); //RETURNS BODY
console.log(response.body.data); //RETURNS UNDEFINED EVEN THOUGH IT EXISTS
})
.catch(function(error){
console.log(error);
});