Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 爱奥尼亚AWS移动集线器启动器问题_Amazon Web Services_Ionic Framework_Ionic3_Aws Mobilehub - Fatal编程技术网

Amazon web services 爱奥尼亚AWS移动集线器启动器问题

Amazon web services 爱奥尼亚AWS移动集线器启动器问题,amazon-web-services,ionic-framework,ionic3,aws-mobilehub,Amazon Web Services,Ionic Framework,Ionic3,Aws Mobilehub,我按照上的说明将该应用程序导入我的AWS Mobile Hub项目,并将我的项目AWS-config.js下载到src/assets。当我尝试为应用程序提供服务时,我收到一个运行时错误: Runtime Error: aws_cognito_region is not defined Stack: ReferenceError: aws_cognito_region is not defined at new Cognito (http://localhost:8100/build

我按照上的说明将该应用程序导入我的AWS Mobile Hub项目,并将我的项目AWS-config.js下载到src/assets。当我尝试为应用程序提供服务时,我收到一个运行时错误:

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)
如有任何见解,将不胜感激

编辑:我在app.config.ts代码下面添加了一段aws-config.js文件(省略顶部包含aws mobile hub项目详细信息的常量声明)

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'});

您需要使用AWS信息(应用程序id、池id等)配置src/app/app.config。

我通过转到AWS-config.js并删除定义的每个变量上的单引号解决了此问题。所以如果你有这个:

const 'aws_cognito_region' = 'us-east-1';
更改为:

const aws_cognito_region = 'us-east-1';

谢谢你的回复。这都是来自爱奥尼亚的预制代码,所以这就是我感到困惑的原因。我编辑了上面的问题并添加了app.config以及aws-config.js文件的功能部分(我在顶部添加了常量声明,其中包含我的应用程序的所有aws项目详细信息,但它们肯定在那里,包括aws\u cognito\u区域)。