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/"}不理解这段函数式编程,看不懂,谁能详细解释下?### 你期待的结果是什么?实际看到的错误信息又是什么?
添加回答
举报
0/150
提交
取消