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)); */ ```pull/18363/head
parent
bd98a445d1
commit
d06487708d
|
@ -87,7 +87,7 @@ The client library is available on the following CDNs:
|
|||
|
||||
The following code creates and starts a connection. The hub's name is case insensitive.
|
||||
|
||||
[!code-javascript[Call hub methods](javascript-client/sample/wwwroot/js/chat.js?range=9-13,43-45)]
|
||||
[!code-javascript[Call hub methods](javascript-client/sample/wwwroot/js/chat.js?range=9-13,28-51)]
|
||||
|
||||
### Cross-origin connections
|
||||
|
||||
|
|
Loading…
Reference in New Issue