不理解这段函数式编程,看不懂

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/"

}


不理解这段函数式编程,看不懂,谁能详细解释下?


### 你期待的结果是什么?实际看到的错误信息又是什么?


有只小跳蛙
浏览 898回答 4
4回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript