我在Angular应用程序中有以下代码段,该代码段调用了运行在端口8080上的Spring REST服务。该代码的问题在于,此POST请求的订阅无法正常工作:
this.http.post<{'username': string,'score': number}>('http://localhost:8080/setScore',{
'username': username,
'score': score
},{
headers: new HttpHeaders().append('Authorization',authToken)
}).subscribe(data => {
console.log('DATA');
}, error => {
console.log('ERROR');
});
它不在控制台中记录DATA或ERROR。