是基于的p
基本使用:fetch(url ,{method:'GET'}).then(data => data);
fetch(url ,{
method:'POST',
headers : new Headers({
"Content-Type" : 'application/x-www-from-urlencoded'
}),
body : new URLSearchParms([[name:'tan'],['age' :18]]).toString(),
credentials : 'include' //加上此字段,可强制带上cookie
})
.then(data => data);
注意:
fetch不会默认的接受发送cookie,所以需要设置