-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
41 lines (39 loc) · 873 Bytes
/
utils.js
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
import axios from 'axios';
import { RDS_API_URL_SELF } from './constants.js';
export async function getUserId(response) {
try {
return response.data.username;
} catch (error) {
console.error(error);
throw error;
}
}
export async function getRDSUserSelfDetails(rdsCookie = '') {
try {
const apiData = {
status: 500,
data: {},
};
await axios({
method: 'get',
url: RDS_API_URL_SELF,
headers: {
Cookie: rdsCookie,
},
})
.then((response) => {
if (response.status === 200) {
apiData.status = 200;
apiData.data = response.data;
}
})
.catch((error) => {
apiData.status = error.response.status;
apiData.data = error.response.data;
});
return apiData;
} catch (error) {
console.error(error);
throw error;
}
}