Skip to content

Commit 2d45da3

Browse files
committed
docs: Elaborate on RestEndpoint fetchResponse and parseResponse
1 parent d51862d commit 2d45da3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

docs/rest/api/RestEndpoint.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,15 +695,22 @@ async function getAuthToken() {
695695

696696
### fetchResponse(input, init): Promise {#fetchResponse}
697697

698-
Performs the [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) call
698+
Performs the [fetch(input, init)](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) call. When
699+
[response.ok](https://developer.mozilla.org/en-US/docs/Web/API/Response/ok) is not `true` (like 404),
700+
will throw a NetworkError.
699701

700702
### parseResponse(response): Promise {#parseResponse}
701703

702-
Takes the [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) and parses via .text() or .json()
704+
Takes the [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) and parses via [.text()](https://developer.mozilla.org/en-US/docs/Web/API/Response/text) or [.json()](https://developer.mozilla.org/en-US/docs/Web/API/Response/json) depending
705+
on ['content-type' header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type) having 'json' (e.g., `application/json`).
706+
707+
If `status` is 204, resolves as `null`.
708+
709+
Override this to handle other response types like [arrayBuffer](https://developer.mozilla.org/en-US/docs/Web/API/Response/arrayBuffer)
703710

704711
### process(value, ...args): any {#process}
705712

706-
Perform any transforms with the parsed result. Defaults to identity function.
713+
Perform any transforms with the parsed result. Defaults to identity function (do nothing).
707714

708715
:::tip
709716

0 commit comments

Comments
 (0)