useStream refactoring (#40)

This commit is contained in:
Kilin Mikhail
2020-12-28 20:03:06 +03:00
committed by GitHub
parent 45a7694e64
commit 5664469b55
8 changed files with 109 additions and 39 deletions

View File

@ -8,22 +8,31 @@ type User = {
first_name: string;
last_name: string;
};
type Support = {
text: string;
url: string;
};
type UserReponse = {
data: Array<User>;
page: number;
per_page: number;
support: {
text: string;
url: string;
}
support: Support;
total: number;
total_pages: number;
};
type UserFindResponse = {
data: User;
support: Support;
}
const ROOT_URL = 'https://reqres.in/api/users';
export const usersApi = makeApi({
request: async () => {
const {data} = await http.get<void, UserReponse>('https://reqres.in/api/users');
const {data} = await http.get<void, UserReponse>(ROOT_URL);
return data;
},
findById: async (id: string) => {
const {data} = await http.get<void, UserFindResponse>(`${ROOT_URL}/${id}`);
return data;
}
});