Members
headers
Get a Headers instance as defined by the fetch API.
url
Get a string representation of the URL used for HTTP requests.
Methods
at(…segments) → {Plug}
Get a new Plug, based on the current one, with the specified path segments added.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
segments |
String |
<repeatable> |
The segments to be added to the new Plug instance. |
Returns:
The Plug with the segments included.
- Type
- Plug
delete() → {Promise}
Perform an HTTP DELETE request.
Returns:
A Promise that, when resolved, yields the {Response} object as defined by the fetch API.
- Type
- Promise
get(methodopt) → {Promise}
Perform an HTTP GET Request.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
method |
String |
<optional> |
GET | The HTTP method to set as part of the GET logic. |
Returns:
A Promise that, when resolved, yields the {Response} object as defined by the fetch API.
- Type
- Promise
head() → {Promise}
Perform an HTTP HEAD request.
Returns:
A Promise that, when resolved, yields the {Response} object as defined by the fetch API.
- Type
- Promise
options() → {Promise}
Perform an HTTP OPTIONS request.
Returns:
A Promise that, when resolved, yields the {Response} object as defined by the fetch API.
- Type
- Promise
post(body, mime, methodopt) → {Promise}
Perform an HTTP POST request.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
body |
String | The body of the POST. | ||
mime |
String | The mime type of the request, set in the `Content-Type` header. | ||
method |
String |
<optional> |
POST | The HTTP method to use with the POST logic. |
Returns:
A Promise that, when resolved, yields the {Response} object as defined by the fetch API.
- Type
- Promise
put(body, mime) → {Promise}
Perform an HTTP PUT request.
Parameters:
| Name | Type | Description |
|---|---|---|
body |
String | The body of the PUT. |
mime |
String | The mime type of the request, set in the `Content-Type` header. |
Returns:
A Promise that, when resolved, yields the {Response} object as defined by the fetch API.
- Type
- Promise
withFollowRedirects() → {Plug}
Get a new Plug, based on the current one, with follow redirects enabled
Returns:
A new Plug instance with follow redirects enabled
- Type
- Plug
withHeader(key, value) → {Plug}
Get a new Plug, based on the current one, with the specified header added.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
String | The name of the header to add. |
value |
String | The value of the header. |
Returns:
A new Plug instance with the header included.
- Type
- Plug
withHeaders(values) → {Plug}
Get a new Plug, based on the current one, with the specified headers added.
Parameters:
| Name | Type | Description |
|---|---|---|
values |
Object | A key-value list of the headers to include. |
Returns:
A new Plug instance with the headers included.
- Type
- Plug
withoutFollowRedirects() → {Plug}
Get a new Plug, based on the current one, with follow redirects disabled
Returns:
A new Plug instance with follow redirects disabled
- Type
- Plug
withoutHeader(key) → {Plug}
Get a new Plug, based on the current one, with the specified header removed.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
String | The name of the header in the current Plug to remove. |
Returns:
A new Plug instance with the header excluded.
- Type
- Plug
withoutParam(key) → {Plug}
Get a new Plug, based on the current one, with the specified query parameter removed.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
String | The key name of the query parameter in the current Plug to remove. |
Returns:
A new Plug instance with the query parameter excluded.
- Type
- Plug
withParam(key, value) → {Plug}
Get a new Plug, based on the current one, with the specified query parameter added.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
String | The key name of the query parameter. |
value |
String | Number | Boolean | A value that will be serialized to a string and set as the query parameter value. |
Returns:
A new Plug instance with the query parameter included.
- Type
- Plug
withParams(values) → {Plug}
Get a new Plug, based on the current one, with the specified query parameters added.
Parameters:
| Name | Type | Description |
|---|---|---|
values |
Object | A key-value list of the query parameters to include. |
Returns:
A new Plug instance with the query parameters included.
- Type
- Plug