# 6.其他

# 6.1 使用fetch函数发送AJAX请求

btn.onclick = function () {
	fetch('http://127.0.0.1:8000/fetch-server',{
        // 请求方法
        method: 'POST',
        // 请求头
        headers: {
            name: 'Wing'
        },
        // 请求体
        body: 'username=admin&password=admin'
    }).then(res => {
        // return res.text();
        return res.json();
    }).then( res=> {
        console.log(res)
    })
}
更新时间: 6/29/2021, 4:20:37 PM