dotnet / dotnet/aspnetcore

Intercept HTTP errors in SignalR JavaScript Client

Open
#39,079 9 comments 1 reaction 0 assignees View on GitHub
area-signalr enhancement
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

This is more of a question then a issue.
I'm using the @microsoft/signalr (v.6.0.0) javascript client in my Vue project.
This is my Connection Builder

`client = new HubConnectionBuilder()
.withUrl('/chat', { accessTokenFactory: () => IdService.getToken() })
.configureLogging(LogLevel.None)
.withAutomaticReconnect()
.build()`

Later when I start the connection:
`client.start().then(() => {
console.log('Connected')
}).catch((err) => {
console.error(err)
})`

What I would like to do is, if there is a error in the moment of starting the connection, I would like to know the HTTP status code from the catched error. Like this:
`client.start().then(() => {
console.log('Connected')
}).catch((err) => {
console.error(err.response.status)
})`

The problem is, the error that is getting catched is only a string. Of course I could filter the status code from the string but that seems wrong.
So my question is, is there any way or method to get the error codes?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.