[P0] API Wrapper
Opened this issue · 0 comments
SirajChokshi commented
Create an API wrapper (and interfaces for models) for the frontend. Functions can be async and should belong to their 'model' or interface on the frontend.
Pseudocode Wrapper Example:
// defined in ./utils/types
interface Model {
id: string;
...
}
// utilities
export ModelAPI {
get: async ({params}) => Promise<Model[]> // function that returns promise for getting all of this Model,
...
}
in usage
// myscript.ts
import ModelAPI from '../utils/ModelAPI';
async function getResults = () => {
const myParams = { ... };
const res = await ModelAPI.get(myParams);
return res;
}
console.log(res);