const TOKEN = "123"
const ROOT = "//www.baidu.com"
const root = createAPI => (...args) => {
const result = createAPI(...args)
return {...result, url: `${ROOT}${result.url}`}
}
const auth = createAPI => (...args) => {
const result = createAPI(...args)
return {
...result,
headers: {...result.headers, authorization: `Bearer ${TOKEN}`},
}
}
const projects = team => {
return {
url: `/api/0/teams/${team}/projects/`,
}
}
root(auth(projects))("fe")
//
{
headers: {authorization: "Bearer 123"}
url: "//www.baidu.com/api/0/teams/fe/projects/"
}
,
-sharp-sharp-sharp