useStream refactoring (#40)
This commit is contained in:
@ -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;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user