Updated with more secure modelling on backend
This commit is contained in:
@@ -23,6 +23,22 @@ export const todosApi = createApi({
|
||||
: [],
|
||||
}),
|
||||
|
||||
getActiveTodos: build.query<Todo[], void>({
|
||||
query: () => ({
|
||||
url: `api/todos`,
|
||||
params: {
|
||||
onlyActive: true,
|
||||
},
|
||||
}),
|
||||
providesTags: (result) =>
|
||||
result
|
||||
? [
|
||||
...result.map(({ id }) => ({ type: "todo" as const, id })),
|
||||
{ type: "todo", id: "LIST" },
|
||||
]
|
||||
: [],
|
||||
}),
|
||||
|
||||
createTodo: build.mutation<string, Partial<Todo>>({
|
||||
query(body) {
|
||||
return {
|
||||
|
@@ -6,7 +6,7 @@ import { todosApi } from "@src/infrastructure/apis/todosApi";
|
||||
import { AddTodo } from "@src/components/todos/addTodo";
|
||||
|
||||
const HomePage = () => {
|
||||
const { data, isLoading } = todosApi.useGetAllTodosQuery();
|
||||
const { data, isLoading } = todosApi.useGetActiveTodosQuery();
|
||||
|
||||
if (isLoading) {
|
||||
return "loading...";
|
||||
|
Reference in New Issue
Block a user