/
Percival
/
reactJS_course
Обзор
Документация
Войти
/
Percival
/
reactJS_course
Код
Запросы
4
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
task3
task_1_fsd/src/entities/task/api/taskApi.ts
24 строки
769 B
Rituparn
Fixed the name not rendering for tasks
09 окт 2025, 13:57
09 окт 2025, 13:57
473265a
Код
Авторство
О чём код?
import type { Task } from 'entities/task/model/types' import { baseApi } from 'shared/api/baseApi' type RemoteTask = { userId?: number; id: number; todo: string; completed: boolean } type TodosResponse = { todos: RemoteTask[]; total: number; skip: number; limit: number } export const tasksApi = baseApi.injectEndpoints({ endpoints: (build) => ({ getTasks: build.query<Task[], void>({ query: () => 'todos', transformResponse: (response: TodosResponse): Task[] => response.todos.map((t) => ({ id: String(t.id), title: t.todo, completed: t.completed, userId: t.userId, })), providesTags: ['Tasks'], }), }), overrideExisting: false, }) export const { useGetTasksQuery } = tasksApi