|
1 | 1 |
|
2 | 2 | # Fetch |
3 | 3 |
|
4 | | -JavaScript can send network requests to the server and load new information whenever is needed. |
| 4 | +JavaScript can send network requests to the server and load new information whenever it's needed. |
5 | 5 |
|
6 | 6 | For example, we can use a network request to: |
7 | 7 |
|
@@ -66,7 +66,7 @@ if (response.ok) { // if HTTP-status is 200-299 |
66 | 66 | - **`response.formData()`** -- return the response as `FormData` object (explained in the [next chapter](info:formdata)), |
67 | 67 | - **`response.blob()`** -- return the response as [Blob](info:blob) (binary data with type), |
68 | 68 | - **`response.arrayBuffer()`** -- return the response as [ArrayBuffer](info:arraybuffer-binary-arrays) (low-level representaion of binary data), |
69 | | -- additionally, `response.body` is a [ReadableStream](https://streams.spec.whatwg.org/#rs-class) object, it allows to read the body chunk-by-chunk, we'll see an example later. |
| 69 | +- additionally, `response.body` is a [ReadableStream](https://streams.spec.whatwg.org/#rs-class) object, it allows you to read the body chunk-by-chunk, we'll see an example later. |
70 | 70 |
|
71 | 71 | For instance, let's get a JSON-object with latest commits from GitHub: |
72 | 72 |
|
@@ -230,7 +230,7 @@ But, as we're going to send JSON, we use `headers` option to send `application/j |
230 | 230 |
|
231 | 231 | We can also submit binary data with `fetch` using `Blob` or `BufferSource` objects. |
232 | 232 |
|
233 | | -In this example, there's a `<canvas>` where we can draw by moving a mouse over it. A click on the "submit" button sends the image to server: |
| 233 | +In this example, there's a `<canvas>` where we can draw by moving a mouse over it. A click on the "submit" button sends the image to the server: |
234 | 234 |
|
235 | 235 | ```html run autorun height="90" |
236 | 236 | <body style="margin:0"> |
|
0 commit comments