Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[P0] API Wrapper #11

Open
SirajChokshi opened this issue Apr 19, 2021 · 0 comments
Open

[P0] API Wrapper #11

SirajChokshi opened this issue Apr 19, 2021 · 0 comments
Assignees
Labels

Comments

@SirajChokshi
Copy link
Member

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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants