Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add axios and create a .env file #83

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions dashboard/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_BASE_URL=http://localhost
1 change: 1 addition & 0 deletions dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@tanstack/react-query": "^5.45.1",
"@tanstack/react-table": "^8.17.3",
"@vitejs/plugin-react": "^4.3.1",
"axios": "^1.7.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"flat": "^6.0.1",
Expand Down
54 changes: 52 additions & 2 deletions dashboard/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions dashboard/src/api/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import type { Tree } from '../types/tree/Tree';

import http from "./api"

Check failure on line 5 in dashboard/src/api/Tree.tsx

View workflow job for this annotation

GitHub Actions / lint-js

Replace `"./api"` with `'./api';`

Check failure on line 5 in dashboard/src/api/Tree.tsx

View workflow job for this annotation

GitHub Actions / lint-js

Replace `"./api"` with `'./api';`

const fetchTreeCheckoutData = async (): Promise<Tree[]> => {
const res = await fetch('/api/tree');
if (!res.ok) {
throw new Error('Request to /api/tree response was not ok');
}
return res.json();
};
const res = await http.get('/api/tree/');

Check failure on line 8 in dashboard/src/api/Tree.tsx

View workflow job for this annotation

GitHub Actions / lint-js

Delete `··`

Check failure on line 8 in dashboard/src/api/Tree.tsx

View workflow job for this annotation

GitHub Actions / lint-js

Delete `··`
return res.data;

Check failure on line 9 in dashboard/src/api/Tree.tsx

View workflow job for this annotation

GitHub Actions / lint-js

Delete `··`

Check failure on line 9 in dashboard/src/api/Tree.tsx

View workflow job for this annotation

GitHub Actions / lint-js

Delete `··`
}

Check failure on line 10 in dashboard/src/api/Tree.tsx

View workflow job for this annotation

GitHub Actions / lint-js

Insert `;`

Check failure on line 10 in dashboard/src/api/Tree.tsx

View workflow job for this annotation

GitHub Actions / lint-js

Insert `;`

export const useTreeTable = (): UseQueryResult => {
return useQuery({ queryKey: ['treeData'], queryFn: fetchTreeCheckoutData });
Expand Down
7 changes: 7 additions & 0 deletions dashboard/src/api/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import axios from "axios"

Check failure on line 1 in dashboard/src/api/api.ts

View workflow job for this annotation

GitHub Actions / lint-js

Replace `"axios"` with `'axios';`

Check failure on line 1 in dashboard/src/api/api.ts

View workflow job for this annotation

GitHub Actions / lint-js

Replace `"axios"` with `'axios';`

const API_BASE_URL = import.meta.env.VITE_API_BASE_URL

Check failure on line 3 in dashboard/src/api/api.ts

View workflow job for this annotation

GitHub Actions / lint-js

Insert `;`

Check failure on line 3 in dashboard/src/api/api.ts

View workflow job for this annotation

GitHub Actions / lint-js

Insert `;`

export default axios.create({
baseURL: API_BASE_URL,
});
Loading