Skip to the content.

Dynamic Base URL

基础地址从配置或环境变量动态获取的示例。

import { Fetcher, query } from 'es-fetch-api'

const { getJSON } = new Fetcher(async () => {
    const config = await fetchAppConfig()
    return config.apiBaseUrl
})

export const getUser = id => getJSON('users/detail', query({ id }))

适用场景: