Skip to content

Commit

Permalink
Log error on non-ok http statuses of useToken (#739)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasIO authored Dec 21, 2023
1 parent d80ba8e commit d3bb268
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-ravens-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@livekit/components-react": patch
---

Log error on non-ok http statuses of useToken
6 changes: 6 additions & 0 deletions packages/react/src/hooks/useToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ export function useToken(
log.debug('fetching token');
const params = new URLSearchParams({ ...options.userInfo, roomName });
const res = await fetch(`${tokenEndpoint}?${params.toString()}`);
if (!res.ok) {
log.error(
`Could not fetch token. Server responded with status ${res.status}: ${res.statusText}`,
);
return;
}
const { accessToken } = await res.json();
setToken(accessToken);
};
Expand Down

0 comments on commit d3bb268

Please sign in to comment.