Node.js   发布时间:2022-04-24  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了node.js – 响应sendgrid nodejs Api时未获得的总项数大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
检索列表中的所有收件人: –

`var request = sg.emptyrequest()
  request.queryParams["page"] = '1'
  request.queryParams["page_size"] = '1'
  request.queryParams["list_id"] = '1'
  request.method = 'GET'
  request.path = '/v3/contactdb/lists/{list_iD}/recipients'
  sg.API(request,function (error,responsE) {
    console.log(response.statusCodE)
    console.log(response.body)
    console.log(response.headers)
  });`

这是我的Api回应: –

`{
  "statusCode": 200,"body": {
    "recipients": [
      {
        "created_at": 1486990474,"email": "jones2@example.com","first_name": null,"id": "am9uZXMyQGV4YW1wbGUuY29t","last_clicked": null,"last_emailed": null,"last_name": "tyutyut","last_opened": null,"updated_at": 1486990474
      }
    ]
  },"headers": {
    "server": "Nginx","date": "Mon,20 Feb 2017 07:11:31 GMT","content-type": "application/json","content-length": "1052","connection": "close","access-control-allow-methods": "HEAD,GET,PUT,POST,deletE,OPTIONS,PATCH","access-control-max-age": "21600","access-control-expose-headers": "Link","access-control-allow-origin": "*","x-content-type-options": "nosniff","Strict-transport-security": "max-age=31536000","x-ratelimit-remaining": "0","x-ratelimit-limit": "1","x-ratelimit-reset": "1487574692","powered-by": "Mako"
  }
}`

解决方法

遗憾的是,SendGrid似乎没有提供您正在使用的API中的收件人数.但是,它们提供单独的API调用,您可以从中获取收件人的总数:

例如:

var request = sg.emptyrequest();

request.queryParams["list_id"] = '1';
request.method = 'GET';
request.path = '/v3/contactdb/lists/{list_iD}';

sg.API(request,function(error,responsE) {
  console.log(response.statusCodE);
  console.log(response.body);
  console.log(response.body.id); // The list id
  console.log(response.body.Name); // The list name
  console.log(response.body.recipient_count); // The count of all recipients of this list
  console.log(response.headers);
});

大佬总结

以上是大佬教程为你收集整理的node.js – 响应sendgrid nodejs Api时未获得的总项数全部内容,希望文章能够帮你解决node.js – 响应sendgrid nodejs Api时未获得的总项数所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。