Ajax-17: Use fetch function to send ajax request

Basic usage

btn.onclick = function() {
    
    
    fetch('http://localhost:8000/fetch',{
    
    
        // 请求方法
        method: 'POST',
        // 请求头
        headers: {
    
    
            name: 'justin'
        },
        // 请求体
        body: {
    
    
            username: 'jusitn',
            password: 123456
        }
    }).then(value => {
    
    console.log(value);})
}

Guess you like

Origin blog.csdn.net/sinat_41696687/article/details/114755586