CognitoSyncManager
alienintheheights opened this issue · 0 comments
First off, thanks for this really great sample site. It has already saved me a ton of work.
I'm trying to extend the cognito.js class to include CognitoSyncManager and dataset access (put/get). Something like this:
getDataSets () {
Config.credentials.get(function () {
var syncClient = new CognitoSyncManager()
syncClient.openOrCreateDataset('myDataset', function (err, dataset) {
if (err) {
// handle
}
dataset.get('timestamp', function (err, value) {
if (err) {
console.log(err)
}
console.log('timestamp: ' + value)
})
// etc
I added the dependency via npm to package.json:
"amazon-cognito-js": "^1.1.0",
And the import to main.js
import 'amazon-cognito-js'
and this to cognito.js:
import {CognitoSyncManager, Config, CognitoIdentityCredentials} from 'aws-sdk'
Having trouble getting the CognitoSyncManager to recognize the Credentials though. Namely, the line from the CognitoSyncManager constructor
this.provider = AWS.config.credentials
is returning null, breaking everything that follows. Here's an excerpt for their constructor JS:
if (void 0 === AWS)
throw new Error("AWS SDK must be loaded before loading the Sync Manager.");
AWS.CognitoSyncManager = function(a) {
a = a || {};
var b = "CognitoJavaScriptSDK/1";
this.provider = AWS.config.credentials,
this.identityPoolId = this.provider.params.IdentityPoolId,
this.region = AWS.config.region,
this.logger = a.log,
"function" != typeof this.logger && (this.logger = function() {}
),
this.local = new AWS.CognitoSyncManager.LocalStorage({
DataStore: a.DataStore ? a.DataStore : AWS.CognitoSyncManager.StoreLocalStorage
}),
this.remote = new AWS.CognitoSyncManager.RemoteStorage(this.identityPoolId,this.provider),
this.remote.setUserAgent(b)
}
See anything I'm missing?