Angular 在使用角度为4的信号器进行协商请求期间,我遇到未经授权的401错误
在协商请求期间,我使用角度为4的信号R收到未经授权的401错误。这是我的密码Angular 在使用角度为4的信号器进行协商请求期间,我遇到未经授权的401错误,angular,signalr,signalr-hub,Angular,Signalr,Signalr Hub,在协商请求期间,我使用角度为4的信号R收到未经授权的401错误。这是我的密码 this.connection = $.hubConnection('http://localhost:53248/signalr', {useDefaultPath: false, 'Authorization':'Bearer '+localStorage.getItem('access_token')}); this.proxy = this.connection.createHub
this.connection = $.hubConnection('http://localhost:53248/signalr',
{useDefaultPath: false,
'Authorization':'Bearer '+localStorage.getItem('access_token')});
this.proxy = this.connection.createHubProxy('AuctionHub');
private startConnection(): void {
this.connection.start({ jsonp: true }).done((data: any) => {
console.log('Now connected ' + data.transport.name + ', connection ID= ' + data.id);
this.connectionEstablished.emit(true);
this.connectionExists = true;
}).fail((error: any) => {
console.log('Could not connect ' + error);
this.connectionEstablished.emit(false);
});
}
以下是连接到AuctionHub时出现的错误。我应该如何解决我的错误。这是我的密码
this.connection = $.hubConnection('http://localhost:53248/signalr',
{useDefaultPath: false,
'Authorization':'Bearer '+localStorage.getItem('access_token')});
this.proxy = this.connection.createHubProxy('AuctionHub');
private startConnection(): void {
this.connection.start({ jsonp: true }).done((data: any) => {
console.log('Now connected ' + data.transport.name + ', connection ID= ' + data.id);
this.connectionEstablished.emit(true);
this.connectionExists = true;
}).fail((error: any) => {
console.log('Could not connect ' + error);
this.connectionEstablished.emit(false);
});
}
这是控制台中的错误
获取401(未经授权)这里有人帮我吗