Reputation: 118
With https://github.com/google/google-api-nodejs-client I can fetch an email thread and display its all messages properly after decoding body data as like https://developers.google.com/gmail/api/v1/reference/users/threads/get#request
But after displaying one email thread I have a pagination of next/prev email thread.
How can I call api to fetch previous / next email thread ? Can anyone guide me a bit on this? You know, on that single thread details page I have threadID but nothing for next thread / previous thread like pageToken.
Thanks in advance Jewel Ahmed
Upvotes: 1
Views: 872
Reputation: 112877
I would list a page at a time, but if you absolutely have to have a token for the next message, you could just list one message at a time and use the nextPageToken
for the next message.
You will have to do two requests for every message though: list and get the message.
Request
GET https://www.googleapis.com/gmail/v1/users/me/messages?maxResults=1&key={YOUR_API_KEY}
Response
{
"messages": [
{
"id": "154995c3613cd8f9", // Get this message
"threadId": "154995c3613cd8f9"
}
],
"nextPageToken": "07610562483470863557", // Use this next time
"resultSizeEstimate": 1
}
Upvotes: 1