【发布时间】:2018-10-15 17:48:39
【问题描述】:
这是一个新手问题。
我已经测试了 web-api-auth-examples: https://github.com/spotify/web-api-auth-examples
它按预期工作,但我不明白 html 代码如何获取正确的数据
<dt>Display name</dt><dd class="clearfix">{{display_name}}</dd>
在这种情况下,数据来自 app.js 中的响应:
var options = {
url: 'https://api.spotify.com/v1/me',
headers: { 'Authorization': 'Bearer ' + access_token },
json: true
};
request.get(options, function(error, response, body) {
console.log(body);
});
响应是一个 JSON 对象 (https://developer.spotify.com/documentation/web-api/reference/object-model/#user-object-private) 其中有一个 display_name 的键,它是包含以下内容的字符串:
显示在用户个人资料上的名称。如果不可用,则为 null。
我不明白的是 html 文件如何仅通过使用 html 代码中的键名来获取 JSON 对象内容。
【问题讨论】: