I can call the following in the AWS CLI in order to access records of a user:
aws cognito-sync list-records --identity-id 'xxxxxxx' --dataset-name 'xxxxxxx' --identity-pool-id 'xxxxxx'
This specific user does not have any records associated with it, and I receive a empty list for records, however I receive additional information such as count and SyncCount etc.
However when I use the following javascript code in my file, I return an TypeError with no information listed in data. Data returns null. There is additional information to be had that was listed by the AWS CLI call.
var identityId = AWS.config.credentials.identityId;
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: identityPoolId,
IdentityId: identityId,
DatasetName: cognitoDatasetName
});
let cognitosync = new AWS.CognitoSync();
var params = {
DatasetName: cognitoDatasetName,
IdentityId: identityId,
IdentityPoolId: identityPoolId
};
cognitosync.listRecords(params, function (err, data) {
if (err) {
console.log("listRecords: " + err, err.stack);
console.log(data);
} // an error occurred
else {
console.log("listRecords: " + JSON.stringify(data));
var cognitoSyncToken = data.SyncSessionToken;
var cognitoSyncCount = data.DatasetSyncCount;
console.log("SyncSessionToken: " + cognitoSyncToken);
console.log("DatasetSyncCount: " + cognitoSyncCount);
addRecord(cognitoSyncToken, cognitoSyncCount);
}
});