问题描述
我正在使用以下 JS 代码来检索我客户的所有订阅的座位详细信息。
gapi.client.reseller.subscriptions.list()
.then(function(response) {
// Handle the results here (response.result has the parsed body).
console.log("Response",response);
},function(err) { console.error("Execute error",err); });
但是,它也会返回他们的所有其他信息。如何自定义它以便它只返回座位数?
解决方法
Google API 有一个名为 fields
的标准参数,可让您选择包含在响应中的字段 (see documentation on Docs API)。
在适用于 JavaScript 的 Google API 客户端库(又名 gapi
)中,您可以在发出请求时简单地在对象中添加参数。在您的情况下,这应该有效:
gapi.client.reseller.subscriptions.list({
fields: [
'nextPageToken','subscriptions/subscriptionId','subscriptions/seats/numberOfSeats',].join(',')
})
保留您需要的所有字段非常重要,包括 nextPageToken
等控制字段。 You can read more about the format used here。