Skip to content

Intercept HTTP errors in SignalR JavaScript Client #39079

@Wwwolfgang

Description

@Wwwolfgang

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-signalrIncludes: SignalR clients and serversenhancementThis issue represents an ask for new feature or an enhancement to an existing one

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions