adapting and shit
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import Axios from 'axios'
|
||||
import Axios, { AxiosResponse } from 'axios'
|
||||
import React, { createContext, useContext } from 'react'
|
||||
|
||||
type Props = {
|
||||
@@ -9,7 +9,7 @@ type Props = {
|
||||
type Context = {
|
||||
get: <T>(path: string) => Promise<T>
|
||||
patch: <T>(path: string, body: Partial<T>) => Promise<T>
|
||||
post: <T>(path: string, body: Partial<T>) => Promise<T>
|
||||
post: <T, R = T>(path: string, body: Partial<T>) => Promise<R>
|
||||
create: <T>(path: string, body: Partial<T>) => Promise<T>
|
||||
destroy: (path: string) => Promise<string>
|
||||
}
|
||||
@@ -27,8 +27,8 @@ export const AppContextProvider = ({ children, baseURL }: Props) => {
|
||||
const res = await axios.patch<T>(path, body)
|
||||
return res.data
|
||||
}
|
||||
async function post<T>(path: string, body: Partial<T>) {
|
||||
const res = await axios.post<T>(path, body)
|
||||
async function post<T, R = T>(path: string, body: Partial<T>) {
|
||||
const res = await axios.post<T, AxiosResponse<R>>(path, body)
|
||||
return res.data
|
||||
}
|
||||
async function create<T>(path: string, body: Partial<T>) {
|
||||
|
||||
Reference in New Issue
Block a user