Добавление функции враппера для api объектов, доработка http объекта (#36)

This commit is contained in:
Nikolay
2020-12-28 14:05:21 +03:00
committed by GitHub
parent 793fa0583f
commit 9cb663aa65
7 changed files with 108 additions and 163 deletions

View File

@ -0,0 +1,29 @@
import {http} from '../infrastructure/Http';
import {makeApi} from '../utils/makeApi';
type User = {
id: number;
avatar: string;
email: string;
first_name: string;
last_name: string;
};
type UserReponse = {
data: Array<User>;
page: number;
per_page: number;
support: {
text: string;
url: string;
}
total: number;
total_pages: number;
};
export const usersApi = makeApi({
request: async () => {
const {data} = await http.get<void, UserReponse>('https://reqres.in/api/users');
return data;
},
});