简体   繁体   English

VueJS 中的 AWS Amplify API - apiName 是如何形成的?

[英]AWS Amplify API in VueJS - How is apiName formed?

I have the following piece of code from AWS sample repository :我有来自AWS 示例存储库的以下代码:

      let apiName = 'mieElasticsearch';
      let path = '/_search';
      let apiParams = {
        headers: {'Content-Type': 'application/json'},
        queryStringParameters: {'q': query, 'default_operator': 'AND', 'size': 10000}
      };
      let response = await this.$Amplify.API.get(apiName, path, apiParams);

When deployed, the call to the API via $Amplify is made to the expected domain name:部署后,通过 $Amplify 对 API 的调用对预期的域名进行:

https://search-xxx-es-xxxxxxxxxxxxxx.eu-west-2.es.amazonaws.com/_search https://search-xxx-es-xxxxxxxxxxxxxx.eu-west-2.es.amazonaws.com/_search

However, when ran locally the application calls:但是,当在本地运行时,应用程序调用:

https://localhost/analysis/search-xxx-es-xxxxxxxxxxxxxx.eu-west-2.es.amazonaws.com/_search https://localhost/analysis/search-xxx-es-xxxxxxxxxxxxxx.eu-west-2.es.amazonaws.com/_search

I have tried entering the this.$Amplify.API.get using a debugger to see how the URL is formed, but couldn't - the debugger just enters app.js that is shown as blank (unable to fetch sources for the library?).我尝试使用调试器输入this.$Amplify.API.get以查看 URL 是如何形成的,但不能 - 调试器只是输入显示为空白的 app.js(无法获取库的源代码? )。

What could be going wrong here?这里可能出了什么问题?

It appears that the endpoint parameter passed within API configuration object should contain https:// prefix.在 API 配置 object 中传递的端点参数似乎应该包含https://前缀。 Otherwise the current URL is prepended to the apiName否则,当前的 URL 将附加到apiName

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM