import qs from "querystring"
export async function getData(url) {
const result =await fetch(url);
const data=await result.json();
return data;
}
export async function postData(url,data) {
const result =await fetch(url, {
method: "post",
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/x-www-form-urlencoded'
},
body:qs.stringify(data)
})
const data=await result.json();
return data;
}
封装fetch(get和post)
最新推荐文章于 2024-02-29 20:41:32 发布