Closed Mael-RABOT closed 1 year ago
Instead of a bulky class managing the request, create a bigger class that implement a method for each request.
Here is an example of rule set:
Here is an example of implementation:
import * as ApiRoutes from "../config" async function find<T>(target: ApiTarget, id: number | string, config?: AxiosRequestConfig): Promise<T> { const response = await axios.get(ApiRoutes[target] + "/" + id, config) return await response.data }
fetch is replaced by axios.XXX findAll, find and create methods are added to HttpRequestManager, send is removed Error handling is updated to correctly deal with axios errors.
Update the request class manager
Instead of a bulky class managing the request, create a bigger class that implement a method for each request.
Here is an example of rule set:
Here is an example of implementation: