Skip to content

Commit

Permalink
andrew part3
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpeng02 committed Nov 29, 2023
1 parent 13d1957 commit 8126487
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
10 changes: 9 additions & 1 deletion frontend/src/common/redux/backendApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,13 @@ export const backendApi = createApi({
}
},
}),
endpoints: () => ({}),
endpoints: (builder) => ({
getBeginnerMessage: builder.query<{ result: string }, void>({
query: () => {
return {
url: "/api/training/beginner_endpoint",
};
},
}),
}),
});
17 changes: 17 additions & 0 deletions frontend/src/pages/beginner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { backendApi } from "@/common/redux/backendApi";
import { Button } from "@mui/material";
import React from "react";

const Beginner = () => {
const [trigger, result] = backendApi.useLazyGetBeginnerMessageQuery();

return (
<>
<div>Beginner page</div>
<Button onClick={() => trigger()}>Click on me</Button>
{result.data && <div>The backend returned: {result.data.result}</div>}
</>
);
};

export default Beginner;
4 changes: 4 additions & 0 deletions training/training/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
def test(request: HttpRequest):
return 200, {"result": "200 Backend surface test successful"}

@api.get("/beginner_endpoint")
def beginner_endpoint(request: HttpRequest):
return 200, {"result": "This is a response from the backend"}


api.add_router("/datasets/default/", get_default_datasets_router())
api.add_router("/tabular", get_tabular_router())
Expand Down

0 comments on commit 8126487

Please sign in to comment.