You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
135
135
136
136
```js
137
137
let response =fetch(protectedUrl, {
@@ -140,8 +140,7 @@ let response = fetch(protectedUrl, {
140
140
}
141
141
});
142
142
```
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:
145
144
146
145
-`Accept-Charset`, `Accept-Encoding`
147
146
-`Access-Control-Request-Headers`
@@ -164,24 +163,24 @@ let response = fetch(protectedUrl, {
164
163
-`Proxy-*`
165
164
-`Sec-*`
166
165
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.
168
167
169
-
## POST requests
168
+
## POST istekleri
170
169
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:
172
171
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.
179
178
180
-
Let's see examples.
179
+
Hadi örneklere bakalım.
181
180
182
-
## Submit JSON
181
+
## Json Veri Göndermek
183
182
184
-
This code submits a `user`object as JSON:
183
+
Bu kod bir `user`objesini JSON olarak gönderir:
185
184
186
185
```js run async
187
186
let user = {
@@ -203,11 +202,11 @@ let result = await response.json();
203
202
alert(result.message);
204
203
```
205
204
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.
207
206
208
-
## Submit a form
207
+
## Form verisini göndermek
209
208
210
-
Let's do the same with an HTML `<form>`.
209
+
Aynı şeyi bir HTML `<form>`'u ile yapalım.
211
210
212
211
213
212
```html run
@@ -232,13 +231,15 @@ Let's do the same with an HTML `<form>`.
232
231
</script>
233
232
```
234
233
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
236
237
237
-
## Submit an image
238
+
Görsel verisini gönderirken ikili (binary) veri olarak göndermemiz gerekir.
238
239
239
-
We can also submit binary data directly using `Blob`or`BufferSource`.
240
+
Direkt olarak `Blob`veya`BufferSource` kullanarak gönderebiliriz.
240
241
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:
242
243
243
244
```html run autorun height="90"
244
245
<bodystyle="margin:0">
@@ -267,9 +268,9 @@ For example, here's a `<canvas>` where we can draw by moving a mouse. A click on
267
268
</body>
268
269
```
269
270
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`).
271
272
272
-
The`submit()`function can be rewritten without `async/await`like this:
273
+
Ayrıca`submit()`fonksiyonu `async/await`olmadan şu şekilde yazabiliriz:
273
274
274
275
```js
275
276
functionsubmit() {
@@ -284,11 +285,11 @@ function submit() {
284
285
}
285
286
```
286
287
287
-
## Custom FormData with image
288
+
## Görsel içeren Formdata'yı göndermek
288
289
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.
290
291
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.
292
293
293
294
```html run autorun height="90"
294
295
<bodystyle="margin:0">
@@ -324,39 +325,38 @@ Also, servers are usually more suited to accept multipart-encoded forms, rather
324
325
</body>
325
326
```
326
327
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.
328
329
329
-
## Summary
330
+
## Özet
330
331
331
-
A typical fetch request consists of two`awaits`:
332
+
Tipik bir fetch isteği iki bölümden oluşur `awaits`:
332
333
333
334
```js
334
-
let response =awaitfetch(url, options); // resolves with response headers
335
-
let result =awaitresponse.json(); // read body as json
336
-
```
335
+
let response =awaitfetch(url, options); // başlık kurallara göre okunur
336
+
let result =awaitresponse.json(); // gövdeyi json olarak geri döndürü
337
337
338
-
Or, promise-style:
338
+
Veya, promise stilinde:
339
339
```js
340
340
fetch(url, options)
341
341
.then(response => response.json())
342
342
.then(result => /* process result */)
343
343
```
344
344
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`--HTTPdurum 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
349
349
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 JSONobjesine ç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,
356
356
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),
0 commit comments