봉인fetch (get과post)
3398 단어 나는 고급 포장이 있다
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;
}