Skip to content

Commit 0a7f929

Browse files
authored
Merge pull request #1454 from SuperFlyTV/chore/update-openapi-docs
chore: update example in openapi readme
2 parents f24fc3e + ef2a444 commit 0a7f929

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/openapi/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,23 @@ npm install @sofie-automation/openapi
3232
```
3333

3434
```typescript
35-
import { Configuration, PlaylistsApi, ResponseError, API_VERSION } from '@sofie-automation/openapi'
35+
import { API_VERSION, Configuration, PlaylistsApi, SofieApi } from '@sofie-automation/openapi'
3636

3737
const config = new Configuration({
3838
basePath: `http://mysofie:3000/api/${API_VERSION}`,
3939
})
4040

41+
const sofieApi = new SofieApi(config)
4142
const sofieVersion = await sofieApi.index()
43+
4244
if (sofieVersion.status !== 200) throw new Error('Bad initial response code')
4345
// Check Sofie version:
4446
console.log(`Talking to Sofie version ${sofieVersion.result.version}`)
4547

48+
const playlistsApi = new PlaylistsApi(config)
4649
const playlists = await playlistsApi.playlists()
4750

48-
const firstPlaylist = playlists.result[0]
51+
const firstPlaylist = playlists.result ? playlists.result[0] : undefined
4952
if (!firstPlaylist) throw new Error('No playlists found')
5053

5154
await playlistsApi.activate({

0 commit comments

Comments
 (0)