Migrate Traefik Proxy dashboard UI to React
This commit is contained in:
parent
4790e4910f
commit
f16fff577a
324 changed files with 28303 additions and 19567 deletions
16
webui/src/libs/fetchMany.ts
Normal file
16
webui/src/libs/fetchMany.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { Key } from 'swr'
|
||||
|
||||
import { BASE_PATH } from './utils'
|
||||
|
||||
export default async function <JSON>(key: Key): Promise<JSON[] | undefined> {
|
||||
const [baseUrl, params, init] = key as Array<string | string[] | RequestInit>
|
||||
|
||||
if (!params || !Array.isArray(params)) return
|
||||
|
||||
const requests = params.map((param) => {
|
||||
const apiUrl = `${BASE_PATH}${baseUrl}${param}`
|
||||
return fetch(apiUrl, init as RequestInit).then((res) => res.json())
|
||||
})
|
||||
|
||||
return await Promise.all(requests)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue