I have a react App which I will be using to bring in google other contacts and I see that theres a limit for 1000 contacts in each call to google People Api’s.
const getGoogleContacts = async (token) => {
if(!token) throw new Error('Google Auth Token Missing');
let params = {"readMask" : "emailAddresses,names", "pageSize" : "1000"};
let url = `https://people.googleapis.com/v1/otherContacts?${new URLSearchParams(params)}`;
let headers = { Authorization: `Bearer ${token}`};
let rawData = await fetch(url, { headers })
.then(res => res.text());
let parsedJson = JSON.parse(rawData);
let nextPageCheck = checkForNextPageToken(parsedJson);
if(nextPageCheck){
//get the next page contacts.
}
return handleRawContactData(parsedJson);
}
const checkForNextPageToken = (response) => {
if(response.hasOwnProperty('nextPageToken')){
return true;
}
return false;
}