I followed the instructions on the github readme and have imported the app into my AWS Mobile Hub project and downloaded my projects aws-config.js to src/assets. When I attempt to serve the app I get a runtime error:
Runtime Error:
aws_cognito_region is not defined
Stack:
ReferenceError: aws_cognito_region is not defined
at new Cognito (http://localhost:8100/build/main.js:112:36)
at _createClass (http://localhost:8100/build/vendor.js:10975:20)
at _createProviderInstance$1 (http://localhost:8100/build/vendor.js:10949:26)
at resolveNgModuleDep (http://localhost:8100/build/vendor.js:10934:17)
at _createClass (http://localhost:8100/build/vendor.js:10977:29)
at _createProviderInstance$1 (http://localhost:8100/build/vendor.js:10949:26)
at resolveNgModuleDep (http://localhost:8100/build/vendor.js:10934:17)
at NgModuleRef_.get (http://localhost:8100/build/vendor.js:12159:16)
at resolveDep (http://localhost:8100/build/vendor.js:12655:45)
at createClass (http://localhost:8100/build/vendor.js:12525:32)
Any insight would be greatly appreciated.
Edit: I have added below my app.config.ts code as well as a segment of my aws-config.js file (omitting the constant declarations at the top that contain my AWS mobile hub project details)
app.config.ts:
import { Injectable } from '@angular/core';
declare var AWS: any;
declare const aws_mobile_analytics_app_id;
declare const aws_cognito_region;
declare const aws_cognito_identity_pool_id;
declare const aws_user_pools_id;
declare const aws_user_pools_web_client_id;
declare const aws_user_files_s3_bucket;
@Injectable()
export class AwsConfig {
public load() {
// Expects global const values defined by aws-config.js
const cfg = {
"aws_mobile_analytics_app_id": aws_mobile_analytics_app_id,
"aws_cognito_region": aws_cognito_region,
"aws_cognito_identity_pool_id": aws_cognito_identity_pool_id,
"aws_user_pools_id": aws_user_pools_id,
"aws_user_pools_web_client_id": aws_user_pools_web_client_id,
"aws_user_files_s3_bucket": aws_user_files_s3_bucket
};
AWS.config.customUserAgent = AWS.config.customUserAgent + ' Ionic';
return cfg;
}
}
aws-config.js:
const 'aws_cognito_region' = 'us-east-1';
... etc
AWS.config.region = aws_project_region;
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: aws_cognito_identity_pool_id
}, {
region: aws_cognito_region
});
AWS.config.update({customUserAgent: 'MobileHub v0.1'});
I fixed this issue by going to the aws-config.js and removing the single quotes on each of the variables defined. So if you have this:
const 'aws_cognito_region' = 'us-east-1';
Change to this:
const aws_cognito_region = 'us-east-1';