本地主机 - 仅协议方案支持跨源请求



我有以下函数:

this.Locations = axios.get('localhost:8081/fetchData?table=locations').then((res) => {                                         
  return res
})   

在我的应用程序中.js我设置了一个端点"/fetchData",如果我只是在浏览器中执行,它可以正常工作。

为什么我会收到此错误消息?

Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
您需要

指定一个方案,例如http:// .将函数更改为:

this.Locations = axios.get('http://localhost:8081/fetchData?table=locations').then((res) => {                                         
  return res
})   

最新更新