我有一个像这样的 JSON 对象:
[{"user": "poetry2", "following": ["Moderator", "shopaholic3000"]}]
我正在使用这样的 Fetch API:
fetch (`/profile/${username}/following`)
.then(response => response.json())
.then(profiles => {
profiles.forEach(function(profile){
profileDisplay = document.createElement('button');
profileDisplay.className = "list-group-item list-group-item-action";
profileDisplay.innerHTML = `
${profile.following}`;
listFollowing.appendChild(profileDisplay);
})
})
现在,它在同一个按钮中显示以下用户,如下所示:
<button class="list-group-item list-group-item-action">
Moderator,shopaholic3000</button>
如何修改 Fetch 调用以在单独的按钮中显示以下每个用户。更像这样的东西:
<button class="list-group-item list-group-item-action">
Moderator</button>
<button class="list-group-item list-group-item-action">
shopaholic3000</button>
潇潇雨雨
相关分类