處理異步請求

ES6 Fetch

--------------------------------
//基於fetch的基本模塊
fetch
.then(response.something) //定義返回的類型和數據格式
.then(data) // 返回的數據fetch('https://jsonplaceholder.typicode.com/users',{
    method: 'POST',
    body: JSON.strignify({
        username: '張三',
        email: 'elonasdfk@gmail.com',
        userId: 1
    }),
    headers: { 'Content-Type': 'application/json;charset=utf-8'}
})

-----------------------------------------------json

相關文章
相關標籤/搜索