我正在尝试将我的离子/角度应用程序连接到弹簧启动后端。我用postman检查后端,并且能够从get请求中获得结果。当我使用我的应用程序执行此操作时,我得到了#34;发生网络错误"。我只是学习角度 - 但我做另一个请求firebase - 并且该请求工作正常。在做了一些研究后,ppl建议它可能与CORS有关 - 我在弹簧启动应用程序上启用了Cross Origins - 还下载了关闭以确保关闭的扩展。
任何帮助都会很棒!代码如下。
(来自服务)
getTimesheets() {
console.log('Service: getTimesheets()')
console.log('URL: ' + this.url)
return this.http
.get(this.url)
.subscribe(data => {
console.log(data)
});
}
(来自timesheet.ts)
getTimeSheets() {
this.timeSheetService.getTimesheets()
}
答案 0 :(得分:1)
我修好了 - 我忘记了' http://'在网址前......