generated from RealDevSquad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathutil.js
More file actions
41 lines (36 loc) · 957 Bytes
/
util.js
File metadata and controls
41 lines (36 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
export const getUsers = async (tab) => {
let URL = {
in_discord: `${API_BASE_URL}/users/search/?role=in_discord`,
verified: `${API_BASE_URL}/users/search/?verified=true`,
};
try {
const response = await fetch(URL[tab], {
method: 'GET',
credentials: 'include',
headers: {
'Content-type': 'application/json',
},
});
const data = await response.json();
return data.users ?? [];
} catch (err) {
console.error(err);
}
};
export const searchUser = async (searchTerm) => {
let URL = `${API_BASE_URL}/users?search=${searchTerm}&dev=true`; // dev=true is a temporary query param
try {
const response = await fetch(URL, {
method: 'GET',
credentials: 'include',
headers: {
'Content-type': 'application/json',
},
});
const data = await response.json();
return data.users ?? [];
} catch (err) {
console.error(err);
return [];
}
};