You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.
After logging in and getting authenticated credentials for a user I want to create/read datasets for the user in cognito identity pool. I am able to create and read datasets from identity pool after which the records are getting stored in the browser's localStorage. But using 'get' and 'put' methods of "CognitoSyncDataset" in 'amazon-cognito-js' sdk, I am getting values for 'put' but getting "undefined" for get even though it is there in the localStorage. Here's my code:
var syncClient = new AWS.CognitoSyncManager();
syncClient.openOrCreateDataset("myDataset", function(err, dataset) {
dataset.get("testk1", function(err, value) {
if(err) console.log(err);
else{
console.log("Record got:\n");
console.log(value);
}
});
dataset.synchronize({
onSuccess: function(dataset, newRecords) {
console.log('Successfully synchronized ' + newRecords.length + ' new records.');
},
onFailure: function(err) {
console.log('Synchronization failed.');
console.log(err);
},
onConflict: function(dataset, conflicts, callback) {
var resolved = [];
for (var i=0; i<conflicts.length; i++) {
// Take remote version.
// resolved.push(conflicts[i].resolveWithRemoteRecord());
// Or... take local version.
resolved.push(conflicts[i].resolveWithLocalRecord());
// Or... use custom logic.
// var newValue = conflicts[i].getRemoteRecord().getValue() + conflicts[i].getLocalRecord().getValue();
// resolved.push(conflicts[i].resovleWithValue(newValue);
}
dataset.resolve(resolved, function() {
return callback(true);
});
// Or... callback false to stop the synchronization process.
// return callback(false);
}
});
});
The text was updated successfully, but these errors were encountered:
EDIT: After some more testing it appears that this is only an issue when attempting to retrieve datasets that were created in the AWS console. I ran some code that created a dataset, then tried getting it and it worked. Reloading the AWS console shows the newly created dataset as well. So I think this may be not be an issue unique to amazon-cognito-js but one that is linked to how the AWS console creates datasets.
After logging in and getting authenticated credentials for a user I want to create/read datasets for the user in cognito identity pool. I am able to create and read datasets from identity pool after which the records are getting stored in the browser's localStorage. But using 'get' and 'put' methods of "CognitoSyncDataset" in 'amazon-cognito-js' sdk, I am getting values for 'put' but getting "undefined" for get even though it is there in the localStorage. Here's my code:
The text was updated successfully, but these errors were encountered: