Skip to content

Commit

Permalink
fix front end api
Browse files Browse the repository at this point in the history
  • Loading branch information
tcaiger committed Jun 18, 2023
1 parent 8fad698 commit c2e9c67
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/tupaia-web/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import axios from 'axios';
import FetchError from './fetchError';

export const API_URL = import.meta.env.REACT_APP_TUPAIA_WEB_API_URL || 'http://localhost:8100';
export const API_URL = import.meta.env.REACT_APP_TUPAIA_WEB_API_URL || 'http://localhost:8100/v1';

// withCredentials needs to be set for cookies to save @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials
axios.defaults.withCredentials = true;
Expand Down
7 changes: 5 additions & 2 deletions packages/tupaia-web/src/api/queries/useUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import { get } from '../api';

export const useUser = () => {
const userResponse = useQuery('getUser', () => get('getUser'));
const { data } = userResponse;
const { data: user } = userResponse;

const name = `${user?.first_name} ${user?.last_name}`;

return {
...userResponse,
isLoggedIn: !!data?.email,
data: { ...user, name },
isLoggedIn: !!user?.email,
};
};

0 comments on commit c2e9c67

Please sign in to comment.