Full refactor to Typescript
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
export const server = {
|
||||
async get(url: string) {
|
||||
const res = await fetch(url, { credentials: 'include' })
|
||||
return await res.json()
|
||||
},
|
||||
async post<T>(url: string, body?: T) {
|
||||
const res = await fetch(url, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
|
||||
return await res.json()
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user