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
Ben Randall 2020-05-18 08:46:25 -07:00 committed by GitHub
parent bd98a445d1
commit d06487708d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -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