Skip to content

Commit df0d19a

Browse files
authored
Update article.md
1 parent f504b72 commit df0d19a

File tree

1 file changed

+57
-57
lines changed

1 file changed

+57
-57
lines changed

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

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -103,35 +103,35 @@ setTimeout(() => { // 2 saniye sonra gizle
103103
}, 2000);
104104
```
105105

106-
````warn
106+
```warn
107107
Yalnızca bir gövde ayrıştırma yöntemi seçebiliriz.
108-
108+
```
109109
Yanıtı `response.text()` ile aldıysak, gövde içeriği zaten işlenmiş olduğundan `response.json()` çalışmayacaktır.
110110

111-
```js
111+
````js
112112
let text = await response.text(); // yanıt gövdesi çevirildi
113113
let parsed = await response.json(); // hata (yukarıda zaten çevirilmişti)
114114
````
115115

116-
## Headers
116+
## Başlıklar (Headers)
117117

118-
There's a Map-like headers object in `response.headers`.
118+
`response.headers` içinde Map benzeri bir headers nesnesi vardır.
119119

120-
We can get individual headers or iterate over them:
120+
Başlıkları tek tek alabilir veya üzerinde yineleme yapabiliriz:
121121

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

125-
// get one header
125+
// sadece bir başlık alma
126126
alert(response.headers.get('Content-Type')); // application/json; charset=utf-8
127127

128-
// iterate over all headers
128+
// tüm başlıkları çekme
129129
for (let [key, value] of response.headers) {
130130
alert(`${key} = ${value}`);
131131
}
132132
```
133133

134-
To set a header, we can use the `headers` option, like this:
134+
Bir başlık ayarlamak için aşağıdaki `headers` seçeneğini deneyebilirsiniz:
135135

136136
```js
137137
let response = fetch(protectedUrl, {
@@ -140,8 +140,7 @@ let response = fetch(protectedUrl, {
140140
}
141141
});
142142
```
143-
144-
...But there's a list of [forbidden HTTP headers](https://fetch.spec.whatwg.org/#forbidden-header-name) that we can't set:
143+
...Ancak ayarlayamayacağımız yasaklı [HTTP başlıklarının](https://fetch.spec.whatwg.org/#forbidden-header-name) bir listesi var:
145144

146145
- `Accept-Charset`, `Accept-Encoding`
147146
- `Access-Control-Request-Headers`
@@ -164,24 +163,24 @@ let response = fetch(protectedUrl, {
164163
- `Proxy-*`
165164
- `Sec-*`
166165

167-
These headers ensure proper and safe HTTP, so they are controlled exclusively by the browser.
166+
Bu başlıklar düzgün ve güvenli HTTP isteği sağlar, bu nedenle yalnızca tarayıcı tarafından kontrol edilirler.
168167

169-
## POST requests
168+
## POST istekleri
170169

171-
To make a `POST` request, or a request with another method, we need to use `fetch` options:
170+
`POST` isteği veya başka bir yöntemle istek yapmak için `fetch` seçeneklerini kullanmamız gerekir:
172171

173-
- **`method`** -- HTTP-method, e.g. `POST`,
174-
- **`body`** -- one of:
175-
- a string (e.g. JSON),
176-
- `FormData` object, to submit the data as `form/multipart`,
177-
- `Blob`/`BufferSource` to send binary data,
178-
- [URLSearchParams](info:url), to submit the data as `x-www-form-urlencoded`, rarely used.
172+
- **`method`** -- HTTP-methodu, örn. `POST`,
173+
- **`body`** -- örnekler:
174+
- string değer (örn. JSON),
175+
- `FormData` nesnesi olarak göndermek için `form/multipart`,
176+
- `Blob`/`BufferSource` ikili (binary) veri göndermek için,
177+
- [URLSearchParams](info:url), verileri `x-www-form-urlencoded`, göndermek için, nadiren kullanılır.
179178

180-
Let's see examples.
179+
Hadi örneklere bakalım.
181180

182-
## Submit JSON
181+
## Json Veri Göndermek
183182

184-
This code submits a `user` object as JSON:
183+
Bu kod bir `user` objesini JSON olarak gönderir:
185184

186185
```js run async
187186
let user = {
@@ -203,11 +202,11 @@ let result = await response.json();
203202
alert(result.message);
204203
```
205204

206-
Please note, if the body is a string, then `Content-Type` is set to `text/plain;charset=UTF-8` by default. So we use `headers` option to send `application/json` instead.
205+
Kısa bir not, göndereceğim değer string ise, `Content-Type` değerini `text/plain;charset=UTF-8` olarak belirlememiz gerekiyor. Json veri göndereceğimiz için `headers` objesine `application/json` özelliğini ekliyoruz.
207206

208-
## Submit a form
207+
## Form verisini göndermek
209208

210-
Let's do the same with an HTML `<form>`.
209+
Aynı şeyi bir HTML `<form>`'u ile yapalım.
211210

212211

213212
```html run
@@ -232,13 +231,15 @@ Let's do the same with an HTML `<form>`.
232231
</script>
233232
```
234233

235-
Here [FormData](https://xhr.spec.whatwg.org/#formdata) automatically encodes the form, `<input type="file">` fields are handled also, and sends it using `Content-Type: form/multipart`.
234+
Burada [FormData](https://xhr.spec.whatwg.org/#formdata) formu otomatik olarak encode eder, `<input type="file">` alanları işlenir ve, `Content-Type: form/multipart` olarak gönderir.
235+
236+
## Görselleri göndermek
236237

237-
## Submit an image
238+
Görsel verisini gönderirken ikili (binary) veri olarak göndermemiz gerekir.
238239

239-
We can also submit binary data directly using `Blob` or `BufferSource`.
240+
Direkt olarak `Blob` veya `BufferSource` kullanarak gönderebiliriz.
240241

241-
For example, here's a `<canvas>` where we can draw by moving a mouse. A click on the "submit" button sends the image to server:
242+
Örneğin, burada fareyi hareket ettirerek çizim yapabileceğimiz bir `<canvas>` var. "Gönder" butonuna tıklandığında görsel sunucuya gönderilir:
242243

243244
```html run autorun height="90"
244245
<body style="margin:0">
@@ -267,9 +268,9 @@ For example, here's a `<canvas>` where we can draw by moving a mouse. A click on
267268
</body>
268269
```
269270

270-
Here we also didn't need to set `Content-Type` manually, because a `Blob` object has a built-in type (here `image/png`, as generated by `toBlob`).
271+
Burada ayrıca `Content-Type` manuel olarak ayarlamamız gerekmedi, çünkü `Blob` nesnesinin yerleşik bir türü vardır (burada `toBlob` tarafından oluşturulan `image/png`).
271272

272-
The `submit()` function can be rewritten without `async/await` like this:
273+
Ayrıca `submit()` fonksiyonu `async/await` olmadan şu şekilde yazabiliriz:
273274

274275
```js
275276
function submit() {
@@ -284,11 +285,11 @@ function submit() {
284285
}
285286
```
286287

287-
## Custom FormData with image
288+
## Görsel içeren Formdata'yı göndermek
288289

289-
In practice though, it's often more convenient to send an image as a part of the form, with additional fields, such as "name" and other metadata.
290+
Pratikte bir görseli "name" ve diğer meta veriler gibi ek alanlarla birlikte formun bir parçası olarak göndermek genellikle daha uygundur.
290291

291-
Also, servers are usually more suited to accept multipart-encoded forms, rather than raw binary data.
292+
Ayrıca, sunucular genellikle ham ikili veriler yerine çok parçalı kodlanmış formları(multipart-encoded forms) kabul etmeye daha uygundur.
292293

293294
```html run autorun height="90"
294295
<body style="margin:0">
@@ -324,39 +325,38 @@ Also, servers are usually more suited to accept multipart-encoded forms, rather
324325
</body>
325326
```
326327

327-
Now, from the server standpoint, the image is a "file" in the form.
328+
Şimdi, sunucu açısından bakıldığında, görsel formdaki bir "dosya "dır.
328329

329-
## Summary
330+
## Özet
330331

331-
A typical fetch request consists of two `awaits`:
332+
Tipik bir fetch isteği iki bölümden oluşur `awaits`:
332333

333334
```js
334-
let response = await fetch(url, options); // resolves with response headers
335-
let result = await response.json(); // read body as json
336-
```
335+
let response = await fetch(url, options); // başlık kurallara göre okunur
336+
let result = await response.json(); // gövdeyi json olarak geri döndürü
337337

338-
Or, promise-style:
338+
Veya, promise stilinde:
339339
```js
340340
fetch(url, options)
341341
.then(response => response.json())
342342
.then(result => /* process result */)
343343
```
344344

345-
Response properties:
346-
- `response.status` -- HTTP code of the response,
347-
- `response.ok` -- `true` is the status is 200-299.
348-
- `response.headers` -- Map-like object with HTTP headers.
345+
Yanıt(Response) Özellikleri
346+
- `response.status` -- HTTP durum kodunu içerir,
347+
- `response.ok` -- `true` ise değer 200-299 arası olmalıdır
348+
- `response.headers` -- Başlıklarını içeren bir map benzeri nesne döndürür
349349

350-
Methods to get response body:
351-
- **`response.json()`** -- parse the response as JSON object,
352-
- **`response.text()`** -- return the response as text,
353-
- **`response.formData()`** -- return the response as FormData object (form/multipart encoding),
354-
- **`response.blob()`** -- return the response as [Blob](info:blob) (binary data with type),
355-
- **`response.arrayBuffer()`** -- return the response as [ArrayBuffer](info:arraybuffer-binary-arrays) (pure binary data),
350+
Yanıt Gövdesini (Response Body) alma yöntemleri:
351+
- **`response.json()`** -- yanıtı bir JSON objesine çevirir,
352+
- **`response.text()`** -- yanıtı bir text olarak döndürür,
353+
- **`response.formData()`** -- yanıtı bir FormData objesi olarak döndürür (form/multipart encoding),
354+
- **`response.blob()`** -- yanıtı [Blob](info:blob) (binary data tipi) olarak döndürür,
355+
- **`response.arrayBuffer()`** -- yanıtı [ArrayBuffer](info:arraybuffer-binary-arrays) (saf ikili veri (binary)) olarak döndürür,
356356

357-
Fetch options so far:
358-
- `method` -- HTTP-method,
359-
- `headers` -- an object with request headers (not any header is allowed),
360-
- `body` -- string/FormData/BufferSource/Blob/UrlSearchParams data to submit.
357+
Şimdiye kadarki "Fetch" seçenekleri:
358+
- `method` -- HTTP methodları (POST,GET vs,),
359+
- `headers` -- istek başlıklarını içeren bir nesne (herhangi bir başlığa izin verilmez),
360+
- `body` -- string/FormData/BufferSource/Blob/UrlSearchParams türünde gönderilecek veriler
361361

362-
In the next chapters we'll see more options and use cases.
362+
Sonraki bölümlerde daha fazla seçenek ve kullanım durumu göreceğiz.

0 commit comments

Comments
 (0)