We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 150be85 commit 46fc10dCopy full SHA for 46fc10d
1 file changed
src/components/TopBar/TopBar.tsx
@@ -145,10 +145,20 @@ export class ListRoomsButton extends React.Component<{}> {
145
refreshRooms = async () => {
146
if (this.context.user) {
147
const token = await this.context.user.getIdToken();
148
- const response = await fetch(
149
- serverPath + `/listRooms?uid=${this.context.user?.uid}&token=${token}`,
150
- );
151
- this.setState({ rooms: await response.json() });
+ try {
+ const response = await fetch(
+ serverPath +
+ `/listRooms?uid=${this.context.user?.uid}&token=${token}`,
152
+ );
153
+ if (!response.ok) {
154
+ this.setState({ rooms: [] });
155
+ return;
156
+ }
157
+ const data = await response.json();
158
+ this.setState({ rooms: Array.isArray(data) ? data : [] });
159
+ } catch {
160
161
162
}
163
};
164
0 commit comments