fetchJSON()
function fetchJSON<V>(
url,
method,
options): Promise<[V | null, Headers]>
Perform an HTTP fetch where input and output data is Json
.
Type Parameters
Type Parameter | Description |
---|---|
V extends Json | Type response is assumed to have. |
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
url | string | undefined | URL from which to fetch. |
method | "POST" | "GET" | "PUT" | "PATCH" | "HEAD" | "DELETE" | "GET" | HTTP method of request. |
options | { body : Json ; headers : {}; timeout : number ; } | ... | Optional parameters. |
options.body ? | Json | undefined | Data to convert to JSON and send in request body. |
options.headers ? | {} | undefined | Additional headers to add to request. |
options.timeout ? | number | undefined | Timeout for request, in milliseconds. Defaults to 1000ms. |
Returns
Promise
<[V
| null
, Headers
]>
Response parsed as JSON, and headers.