Skip to content

Commit f504b72

Browse files
authored
Update article.md
1 parent 875cd38 commit f504b72

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

5-network/01-fetch-basics/article.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,71 +45,72 @@ if (response.ok) { // if HTTP-status is 200-299
4545

4646
Response gövdesini (body) almak için, ek bir yöntem çağrısı yapmamız gerekiyor.
4747

48-
`Response` provides multiple promise-based methods to access the body in various formats:
48+
`Response` gövdesine erişmek için birden fazla format ve özellik vardır:
49+
50+
- **`response.json()`** -- yanıtı JSON nesnesi olarak ayrıştırır,
51+
- **`response.text()`** -- yanıtı metin (text) olarak döndürür,
52+
- **`response.formData()`** -- yanıtı FormData nesnesi olarak döndürür (form/çok parçalı kodlama),
53+
- **`response.blob()`** -- yanıtı Blob türünde döndürür [Blob](info:blob) (binary data tipi (ikili)),
54+
- **`response.arrayBuffer()`** -- yanıtı [ArrayBuffer](info:arraybuffer-binary-arrays) türünde döndürür (saf ikili veri),
55+
- ek olarak, `response.body` bir, [ReadableStream](https://streams.spec.whatwg.org/#rs-class) nesnesidir, gövdeyi parça parça okumaya izin verir, daha sonra bir örnek göreceğiz.
4956

50-
- **`response.json()`** -- parse the response as JSON object,
51-
- **`response.text()`** -- return the response as text,
52-
- **`response.formData()`** -- return the response as FormData object (form/multipart encoding),
53-
- **`response.blob()`** -- return the response as [Blob](info:blob) (binary data with type),
54-
- **`response.arrayBuffer()`** -- return the response as [ArrayBuffer](info:arraybuffer-binary-arrays) (pure binary data),
55-
- 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.
5657

57-
For instance, here we get a JSON-object with latest commits from GitHub:
58+
Örneğin, burada GitHub'dan en son commitleri içeren bir JSON nesnesi alıyoruz:
5859

5960
```js run async
6061
let response = await fetch('https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits');
6162

6263
*!*
63-
let commits = await response.json(); // read response body and parse as JSON
64+
let commits = await response.json(); // yanıt gövdesini okuyun ve JSON olarak ayrıştırın
6465
*/!*
6566

6667
alert(commits[0].author.login);
6768
```
6869

69-
Or, the same using pure promises syntax:
70+
Ya da promises sözdizimi kullanarak aynısını yapabilirsiniz:
7071

7172
```js run
7273
fetch('https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits')
7374
.then(response => response.json())
7475
.then(commits => alert(commits[0].author.login));
7576
```
7677

77-
To get the text:
78+
Metni almak için:
7879
```js
7980
let text = await response.text();
8081
```
8182

82-
And for the binary example, let's fetch and show an image (see chapter [Blob](info:blob) for details about operations on blobs):
83+
Ve binary örneği için, bir görsel getirelim ve gösterelim (bloblar üzerindeki işlemler hakkında ayrıntılar için [Blob](info:blob) bölümüne bakın):
8384

8485
```js async run
8586
let response = await fetch('/article/fetch/logo-fetch.svg');
8687

8788
*!*
88-
let blob = await response.blob(); // download as Blob object
89+
let blob = await response.blob(); // Blob nesnesi olarak indirme
8990
*/!*
9091

9192
// create <img> for it
9293
let img = document.createElement('img');
9394
img.style = 'position:fixed;top:10px;left:10px;width:100px';
9495
document.body.append(img);
9596

96-
// show it
97+
// Gösterme
9798
img.src = URL.createObjectURL(blob);
9899

99-
setTimeout(() => { // hide after two seconds
100+
setTimeout(() => { // 2 saniye sonra gizle
100101
img.remove();
101102
URL.revokeObjectURL(img.src);
102103
}, 2000);
103104
```
104105

105106
````warn
106-
We can choose only one body-parsing method.
107+
Yalnızca bir gövde ayrıştırma yöntemi seçebiliriz.
107108
108-
If we got the response with `response.text()`, then `response.json()` won't work, as the body content has already been processed.
109+
Yanıtı `response.text()` ile aldıysak, gövde içeriği zaten işlenmiş olduğundan `response.json()` çalışmayacaktır.
109110
110111
```js
111-
let text = await response.text(); // response body consumed
112-
let parsed = await response.json(); // fails (already consumed)
112+
let text = await response.text(); // yanıt gövdesi çevirildi
113+
let parsed = await response.json(); // hata (yukarıda zaten çevirilmişti)
113114
````
114115

115116
## Headers

0 commit comments

Comments
 (0)