/*
* 基于 window下的 ajax ,fetch函数的封装
* auther:shuke
* date:20221229
* version:1.0
* */
const BASEURL="http://localhost:6600/api"
export default {
getData(url,params={}){
url=BASEURL+url
const str=(Object.keys(params)).map((item)=> item+"="+params[item]).join("&")
return fetch(url+"?"+str).then(res=>res.json())
},
postData(url,data={}){
url=BASEURL+url
console.log(url, data);
return fetch(url,{
method:"POST",
body:JSON.stringify(data),
headers:{
"Content-type":"application/json"
}
}).then(res=>res.json())
}
}