Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/454.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
Javascript 不知道为什么要添加额外的参数';未定义';在AWS ec2上的api url中?_Javascript_Amazon Ec2_Ecmascript 6 - Fatal编程技术网

Javascript 不知道为什么要添加额外的参数';未定义';在AWS ec2上的api url中?

Javascript 不知道为什么要添加额外的参数';未定义';在AWS ec2上的api url中?,javascript,amazon-ec2,ecmascript-6,Javascript,Amazon Ec2,Ecmascript 6,在CONSTANTS.API_URL='“'中${CONSTANTS.API_URL}/API/template/list这就是我在vue js前端绑定API URL的内容。当API调用rom vue js时,我得到了这个URLhttp://52.220.223.145/undefined/api/task/list。在此URL中,自动添加未定义的额外参数。我不知道ec2服务器上出了什么问题。当我在本地计算机上运行时,它工作正常 http.post(`${CONSTANTS.API_URL}/a

在CONSTANTS.API_URL='“'中<代码>${CONSTANTS.API_URL}/API/template/list这就是我在vue js前端绑定API URL的内容。当API调用rom vue js时,我得到了这个URL
http://52.220.223.145/undefined/api/task/list
。在此URL中,自动添加未定义的额外参数。我不知道ec2服务器上出了什么问题。当我在本地计算机上运行时,它工作正常

http.post(`${CONSTANTS.API_URL}/api/template/list`, this.searchObj)
    .then((result) => {
      this.templates = result.rows
      this.searchObj = {}
      this.getTotalPages(result)
      console.log('template list', result)
    })
    .catch((httpException) => {
      console.log(httpException)
      return Utils.notify(httpException.message, 'error')
    })
施里坎特

如果您从代码中获取此信息:

  `${CONSTANTS.API_URL}/api/template/list`
那么${CONSTANTS.API_URL}必须返回一些未定义的值。
请检查${CONSTANTS.API_URL}。

dev.env.js
文件中,我将API主机设置为
http://52.220.223.145
,但是,当我在ec2 aws上升级时,我忘记了添加api主机
http://52.220.223.145
prod.env.js

中,您可以添加如何制作API callI的代码吗?请检查上面添加的代码。您使用的是哪个
http
库以及从何处进行调用。。。浏览器/节点(同构的东西等)获取bb npm库啊,我看不出你粘贴的代码和信息有任何真正的问题。。。也许您可以尝试调试/中断XHR请求,并查看堆栈跟踪以了解更多。。。如果您使用的是Chrome,那么应该没有问题。