|
1 | 1 |
|
2 | 2 | # Fetch API |
3 | 3 |
|
4 | | -So far, we know quite a bit about fetch. |
| 4 | +До сих пор мы узнали лишь немного про `fetch`. |
5 | 5 |
|
6 | | -Now let's see the rest of API, to cover all its abilities. |
| 6 | +Теперь давайте рассмотрим оставшуюся часть API, чтобы охватить все его возможности. |
7 | 7 |
|
8 | | -Here's the full list of all possible fetch options with their default values (alternatives in comments): |
| 8 | +Вот полный перечень всех возможных параметров с их значениями по умолчанию (альтернативные значения в комментариях): |
9 | 9 |
|
10 | 10 | ```js |
11 | 11 | let promise = fetch(url, { |
12 | | - method: "GET", // POST, PUT, DELETE, etc. |
| 12 | + method: "GET", // POST, PUT, DELETE, и т.д. |
13 | 13 | headers: { |
14 | | - "Content-Type": "text/plain;charset=UTF-8" // for a string body, depends on body |
| 14 | + "Content-Type": "text/plain;charset=UTF-8" // для строкового тела, зависит от тела сообщения |
15 | 15 | }, |
16 | | - body: undefined // string, FormData, Blob, BufferSource, or URLSearchParams |
17 | | - referrer: "about:client", // "" for no-referrer, or an url from the current origin |
| 16 | + body: undefined // строка, FormData, Blob, BufferSource, или URLSearchParams |
| 17 | + referrer: "about:client", // "" для no-referrer, или URL-адрес текущего источника |
18 | 18 | referrerPolicy: "no-referrer-when-downgrade", // no-referrer, origin, same-origin... |
19 | 19 | mode: "cors", // same-origin, no-cors |
20 | 20 | credentials: "same-origin", // omit, include |
21 | | - cache: "default", // no-store, reload, no-cache, force-cache, or only-if-cached |
| 21 | + cache: "default", // no-store, reload, no-cache, force-cache, или only-if-cached |
22 | 22 | redirect: "follow", // manual, error |
23 | | - integrity: "", // a hash, like "sha256-abcdef1234567890" |
| 23 | + integrity: "", // хеш, например "sha256-abcdef1234567890" |
24 | 24 | keepalive: false, // true |
25 | | - signal: undefined, // AbortController to abort request |
| 25 | + signal: undefined, // AbortController для отмены запроса |
26 | 26 | window: window // null |
27 | 27 | }); |
28 | 28 | ``` |
29 | 29 |
|
30 | | -An impressive list, right? |
| 30 | +Впечатляющий список, верно? |
31 | 31 |
|
32 | | -We fully covered `method`, `headers` and `body` in the chapter <info:fetch-basics>. |
| 32 | +Мы полностью рассмотрели `method`, `headers` и `body` в главе <info:fetch-basics>. |
33 | 33 |
|
34 | | -The `signal` option is covered in <info:fetch-abort>. |
| 34 | +Параметр `signal` рассматривается в <info:fetch-abort>. |
35 | 35 |
|
36 | | -Now let's explore the rest of options. |
| 36 | +Теперь давайте разберем оставшиеся параметры. |
37 | 37 |
|
38 | 38 | ## referrer, referrerPolicy |
39 | 39 |
|
40 | | -These options govern how `fetch` sets HTTP `Referer` header. |
| 40 | +Эти параметры определяют как `fetch` устанавливает HTTP-заголовок `Referer`. |
41 | 41 |
|
42 | | -That header contains the url of the page that made the request. In most scenarios, it plays a very minor informational role, but sometimes, for security purposes, it makes sense to remove or modify it. |
43 | | -. |
| 42 | +Этот заголовок содержит URL-адрес страницы, которая сделала запрос. В большинстве случаев, это играет очень незначительную информационную роль, но иногда, в целях безопасности, имеет смысл изменить или удалить его. |
44 | 43 |
|
45 | 44 | **The `referrer` option allows to set any `Referer` within the current origin) or disable it.** |
46 | 45 |
|
|
0 commit comments