首页 > 解决方案 > Axios GET 请求到服务器 - 不是本地主机

问题描述

我想知道是否有人可以对 GET 请求路径的工作方式有所了解。我不擅长网络,所以在这里有点迷路。

我有一个在 PythonAnywhere 上运行的 Flask 应用程序......我用 Vue 构建了一个小应用程序,并正在使用 Axios 向服务器上的 API 发送 GET 请求。然而,我发现当我在 PythonAnywhere 服务器上运行我的应用程序时,只有当我也在本地机器上运行烧瓶应用程序时才会得到响应。我怀疑这是因为我试图将请求发送到http://localhost:5000/api/random2。真的吗?我必须用什么替换它才能将请求发送到我的 PythonAnywhere 应用程序?

 getResults () {
        const path = `http://localhost:5000/api/random2`
        axios.get(path, {
          params: {
            p_a: this.p_a,
            R_eH: this.R_eH,
            a: this.a,
            b: this.b
          } 
        })
        .then(response => {this.result = response.data})
        .catch(error => {
          console.log(error)
        })
    }
  },

谢谢你,雅库布

标签: flaskvue.jsgetaxiospythonanywhere

解决方案


推荐阅读