1. Trang chủ
  2. » Kinh Tế - Quản Lý

cheatsheet fetch

1 0 0
Tài liệu được quét OCR, nội dung có thể không chính xác
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Fetch API Cheatsheet
Chuyên ngành Web Development
Thể loại Cheatsheet
Định dạng
Số trang 1
Dung lượng 4,16 MB

Nội dung

Fetch API cheatsheet.. .thenresponse => console.. logresponse ; fetch"{ur1}?var1=value1&var2=value2" .thenresponse => console.. logresponse ; simple authorization token Bearer querystri

Trang 1

Fetch API cheatsheet

.then(response => console log(response)) ; fetch("{ur1}?var1=value1&var2=value2")

.then(response => console log(response)) ;

fetch('{url}', { mode: ‘cors'

})

.then(response => console log(response)) ; fetch("{ur1}?var1=value1&var2=value2', {

headers: { ‘Authorization’: ‘Bearer {token}'

} })

„then(response => console log(response)) ;

} })

.then(response => console log(response)) ; fetch("{ur1}?var1=value1&var2=value2", {

})

.then(response => console log(response) );

fetch("{ur1}?var1=value1&var2=value2', { method: ‘post’,

headers: { ‘Authorization’: ‘Bearer {token}'

} })

.then(response => console log(response)) ; let formData = new FormData();

formData.append('field1', 'value1');

formData.append('field2', 'value2');

fetch('{url}', { method: ‘post’, body: formData

})

.then(response => console log(response)) ;

fetch('{url}', { method: ‘post’, headers: {

‘Content-Type’: ‘application/json‘ 3

body: JSON.stringify({ "fieldi': 'valuel', "field2': ‘value2'

}) })

.then(response => console log(response)) ; fetch('{url}', {

method: ‘post’,

mode: ‘cors',

headers: { ‘Content-Type’: ‘application/json' >

body: JSON.stringify({ "fieldi': 'value1',

'field2': 'value2"

}) })

.then(response => console log(response)) ;

simple

authorization token (Bearer)

querystring data

CORS

authorization token + querystring data

form data

JSON data

JSON data + CORS

Ngày đăng: 14/09/2024, 17:07

w