es6 fetch body格式

let data={username:"jack",password:"123}
fetch("user",{ 
    method:"POST",
    headers:{
    "Content-Type": "application/x-www-form-urlencoded",
    }, 
    body:"username="+data.username+"&password="+data.password
}).then(
    response => response.json()
).then(
    data => console.log(data)
).catch(
    e => console.error(e)
);

你可能感兴趣的:(web)