Skip to content

Commit d064877

Browse files
authored
Update javascript-client.md (#18348)
Fixing range for `Connect to a hub` section sample code. Current code shows this: ```js const connection = new signalR.HubConnectionBuilder() .withUrl("/chatHub") .configureLogging(signalR.LogLevel.Information) .build(); start(); /* this is here to show an alternative to start, with a then ``` New should show this: ```js const connection = new signalR.HubConnectionBuilder() .withUrl("/chatHub") .configureLogging(signalR.LogLevel.Information) .build(); async function start() { try { await connection.start(); console.log("connected"); } catch (err) { console.log(err); setTimeout(() => start(), 5000); } }; connection.onclose(async () => { await start(); }); // Start the connection. start(); /* this is here to show an alternative to start, with a then connection.start().then(() => console.log("connected")); */ /* this is here to show another alternative to start, with a catch connection.start().catch(err => console.error(err)); */ ```
1 parent bd98a44 commit d064877

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

aspnetcore/signalr/javascript-client.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ The client library is available on the following CDNs:
8787

8888
The following code creates and starts a connection. The hub's name is case insensitive.
8989

90-
[!code-javascript[Call hub methods](javascript-client/sample/wwwroot/js/chat.js?range=9-13,43-45)]
90+
[!code-javascript[Call hub methods](javascript-client/sample/wwwroot/js/chat.js?range=9-13,28-51)]
9191

9292
### Cross-origin connections
9393

0 commit comments

Comments
 (0)