Skip to content

Commit

Permalink
chore: add axios and create a .env file
Browse files Browse the repository at this point in the history
  • Loading branch information
lfjnascimento committed Jul 10, 2024
1 parent 25be3fb commit 65f069a
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 7 deletions.
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 @@ -27,6 +27,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
59 changes: 59 additions & 0 deletions dashboard/pnpm-lock.yaml

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

13 changes: 6 additions & 7 deletions dashboard/src/api/Tree.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { useQuery, UseQueryResult} from "@tanstack/react-query";
import { useQuery, UseQueryResult } from "@tanstack/react-query";

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

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();
import http from "./api"

const fetchTreeCheckoutData = async (): Promise<Tree[]> => {
const res = await http.get('/api/tree/');
return res.data;
}

export const useTreeTable = (): UseQueryResult => {
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"

const API_BASE_URL = import.meta.env.VITE_API_BASE_URL

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

0 comments on commit 65f069a

Please sign in to comment.