【发布时间】:2017-05-09 11:58:58
【问题描述】:
我正在尝试创建一个功能,该功能将通过端点进行分页以获取所有联系人。现在我的承诺是只返回我不明白的数字 2。我希望它返回所有联系人。这是我目前拥有的代码。我希望有人可以帮助我了解如何正确返回联系人数组。
function getContacts(vid,key){
return axios.get('https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=' + key + '&vidOffset=' + vid)
.then(response =>{
//console.log(response.data['has-more'])
//console.log(response.data['vid-offset'])
if (response.data['has-more']){
contacts.push(getContacts(response.data['vid-offset'],key))
if(vid === 0){
return contacts.push(response.data.contacts)
}else{
return response.data.contacts
}
}else{
//console.log(contacts)
return response.data.contacts
}
})
}
【问题讨论】: