您如何阅读 Node.js 中的 API 文档?

How do you read API documentation in Node.js?

我正在尝试阅读 https://github.com/mikeal/bent 上的文档。

我不识字async request(url[, body=null, headers={}])。具体来说,,代表什么?

之前看到过这个问题的答案,也搜索过,没找到。将这个标记为那个的副本会很棒。

下面是这个例子的分步说明:

async request(url[, body=null, headers={}])
  1. async 表示它是一个始终 returns 承诺的异步函数。
  2. url 是第一个参数并且是必需的。
  3. [, args here ]表示括号内的参数是可选的。
  4. [, args here] 中的逗号表示如果包含这些参数,则需要用逗号将每个参数与前一个参数分开。
  5. body=null表示如果不传body参数,默认值为null
  6. headers={}表示如果不传headers参数,默认值为空对象。

因此,您可以像以下任何一种一样调用它:

request(myUrl).then(...).catch(...)
request(myUrl, myBody).then(...).catch(...)
request(myUrl, myBody, myHeaders).then(...).catch(...)