Skip to content

Commit

Permalink
remove client axios usage
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Dec 25, 2024
1 parent 325b301 commit 94dfde2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 38 deletions.
16 changes: 0 additions & 16 deletions dev/testaxios.js

This file was deleted.

13 changes: 0 additions & 13 deletions dev/testexpress.js

This file was deleted.

11 changes: 6 additions & 5 deletions src/components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,12 @@ export default class App extends React.Component<AppProps, AppState> {
// if a vanity name, resolve the url to a room id
if (this.props.vanity) {
try {
const response = await axios.get(
const response = await fetch(
serverPath + '/resolveRoom/' + this.props.vanity,
);
if (response.data.roomId) {
roomId = response.data.roomId;
const data = await response.json();
if (data.roomId) {
roomId = data.roomId;
} else {
this.setState({ overlayMsg: "Couldn't load this room." });
}
Expand All @@ -313,8 +314,8 @@ export default class App extends React.Component<AppProps, AppState> {
} catch (e) {
console.warn('[ALERT] Could not parse saved passwords');
}
const response = await axios.get(serverPath + '/resolveShard' + roomId);
const shard = Number(response.data) || '';
const response = await fetch(serverPath + '/resolveShard' + roomId);
const shard = Number(await response.text()) || '';
const socket = io(serverPath + roomId, {
transports: ['websocket'],
query: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Settings/SettingsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ export const SettingsTab = ({
}
setValidVanity(false);
setValidVanityLoading(true);
const response = await axios.get(serverPath + '/resolveRoom/' + input);
const data = response.data;
const response = await fetch(serverPath + '/resolveRoom/' + input);
const data = await response.json();
setValidVanityLoading(false);
if (
data &&
Expand Down
4 changes: 2 additions & 2 deletions src/components/TopBar/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ export class ListRoomsButton extends React.Component<{}> {
refreshRooms = async () => {
if (this.context.user) {
const token = await this.context.user.getIdToken();
const response = await axios.get(
const response = await fetch(
serverPath + `/listRooms?uid=${this.context.user?.uid}&token=${token}`,
);
this.setState({ rooms: response.data });
this.setState({ rooms: await response.json() });
}
};

Expand Down

0 comments on commit 94dfde2

Please sign in to comment.