From 2ed71840123fece1c82d3d444df42943ab49ffca Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Fri, 11 Nov 2016 18:20:42 -0500 Subject: [PATCH] document optional url arg in request --- docs/request.md | 3 ++- docs/signatures.md | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/request.md b/docs/request.md index df862038..8a52c357 100644 --- a/docs/request.md +++ b/docs/request.md @@ -18,10 +18,11 @@ ### API -`stream = m.request(options)` +`stream = m.request([url,] options)` Argument | Type | Required | Description ---------------------- | --------------------------------- | -------- | --- +`url` | `String` | No | If present, it's equivalent to having the options `{method: "GET", url: url}`. Values passed to the `options` argument override options set via this shorthand. `options.method` | `String` | Yes | The HTTP method to use. This value should be one of the following: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `HEAD` or `OPTIONS`. `options.url` | `String` | Yes | The URL to send the request to. The URL may be either absolute or relative, and it may contain [interpolations](#dynamic-urls). `options.data` | `any` | No | The data to be interpolated into the URL and serialized into the querystring (for GET requests) or body (for other types of requests). diff --git a/docs/signatures.md b/docs/signatures.md index f565e83f..cd3a2b38 100644 --- a/docs/signatures.md +++ b/docs/signatures.md @@ -27,6 +27,14 @@ The **Required** column indicates whether an argument is required or optional. I --- +### Optional arguments + +Function arguments surrounded by square brackets `[ ]` are optional. In the example below, `url` is an optional argument: + +`m.request([url,] options)` + +--- + ### Splats A splat argument means that if the argument is an array, you can omit the square brackets and have a variable number of arguments in the method instead.