Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/docs/src/content/docs/guides/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ To keep sessions alive, refresh the token just before its expiration and reconne
```jsx
const { control } = useChatKit({
api: {
getClientSecret(currentClientSecret) {
async getClientSecret(currentClientSecret) {
if (!currentClientSecret) {
const res = await fetch('/api/chatkit/start', { method: 'POST' })
const {client_secret} = await res.json();
return client_secret
}
const res = await fetch('/api/chatkit/refresh', {
method: 'POST',
body: JSON.stringify({ currentClientSecret })
body: JSON.stringify({ currentClientSecret }),
headers: {
'Content-Type': 'application/json',
},
Expand All @@ -57,15 +57,15 @@ To keep sessions alive, refresh the token just before its expiration and reconne

chatkit.setOptions({
api: {
getClientSecret(currentClientSecret) {
async getClientSecret(currentClientSecret) {
if (!currentClientSecret) {
const res = await fetch('/api/chatkit/start', { method: 'POST' })
const {client_secret} = await res.json();
return client_secret
}
const res = await fetch('/api/chatkit/refresh', {
method: 'POST',
body: JSON.stringify({ currentClientSecret })
body: JSON.stringify({ currentClientSecret }),
headers: {
'Content-Type': 'application/json',
},
Expand Down