File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed
wrongsecrets-balancer/ui/src/pages Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -156,19 +156,20 @@ function DeleteInstanceButton({ team }) {
156
156
}
157
157
158
158
export default function AdminPage ( ) {
159
- const [ teams , setTeams ] = useState ( updateAdminData ( ) ) ;
159
+ const [ teams , setTeams ] = useState ( [ ] ) ;
160
160
const { formatMessage, formatDate } = useIntl ( ) ;
161
161
162
- function updateAdminData ( ) {
163
- return axios
164
- . get ( `/balancer/admin/all` )
165
- . then ( ( { data } ) => {
166
- console . log ( 'getting all teams data' )
167
- setTeams ( data . instances ) ;
168
- } )
169
- . catch ( ( err ) => {
170
- console . error ( 'Failed to fetch current teams!' , err ) ;
171
- } ) ;
162
+ async function updateAdminData ( ) {
163
+ try {
164
+ const response = await fetch ( `/balancer/admin/all` ) ;
165
+ if ( ! response . ok ) {
166
+ throw new Error ( 'Failed to fetch current teams' ) ;
167
+ }
168
+ const data = await response . json ( ) ;
169
+ setTeams ( data . instances ) ;
170
+ } catch ( err ) {
171
+ console . error ( 'Failed to fetch current teams!' , err ) ;
172
+ }
172
173
}
173
174
174
175
useEffect ( ( ) => {
You can’t perform that action at this time.
0 commit comments