Skip to content
Snippets Groups Projects
Commit c7eb6365 authored by Ignacio Bengoa Nion's avatar Ignacio Bengoa Nion
Browse files

Users handling through the Backend implemented - Query parameters added to listUsers

parent 3531a789
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,6 @@ PORT=7999
INSTANCE=TEST
HOST=localhost
USER=root
PASSWORD=Comfortablynumb.07
PASSWORD=password
DB=parameter_database
AUTH_BASE_URL='http://localhost:4000/users'
\ No newline at end of file
AUTH_BASE_URL=http://localhost:4000/users
\ No newline at end of file
......@@ -21,7 +21,8 @@ const create: Handler = async (req: Request, res: Response) => {
const listUsers: Handler = async (req: Request, res: Response) => {
try {
const token: any = req.headers.authorization;
const userList: any = await UserAPI.listUsers(req.query.type, token);
const userList: any = await
UserAPI.listUsers(req.query.type, req.query.limit, req.query.offset, req.query.search, token);
return res.status(200).send(userList);
} catch (error) {
const e = error as Error;
......
......@@ -34,8 +34,17 @@ const login = async (user: any) => {
return res.data;
};
const listUsers = async (userType: any, token: string) => {
const res = await instance.get('/', { headers: { authorization: token }, params: { type: userType } });
const listUsers = async (userType: any, givenLimit: any, givenOffset: any,
givenSearch: any, token: string) => {
const res = await instance.get('/', {
headers: { authorization: token },
params: {
type: userType,
limit: givenLimit,
offset: givenOffset,
search: givenSearch,
},
});
return res.data;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment