export const get = async (url) => {
return await (await fetch(url)).json()
}
export const post = async (url, data) => {
return await (
await fetch(url, {
method: 'put',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
})
).json()
}
export const postBlob = async (url, data) => {
if (!(data instanceof FormData)) {
const fd = new FormData()
Object.keys(data).forEach((o) => {
fd.append(o, data[o])
})
data = fd
}
return await (
await fetch(url, {
method: 'post',
body: data,
headers: {
'Content-Type': 'multipart/form-data'
}
})
).json()
}
export const del = async (url) => {
return await (
await fetch(url, {
method: 'delete'
})
).json()
}
export const put = async (url, data) => {
return await (
await fetch(url, {
method: 'put',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
})
).json()
}
console