Skip to content

Change all API helpers function arguments to object #11

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

Open
mittalyashu opened this issue Feb 22, 2021 · 0 comments
Open

Change all API helpers function arguments to object #11

mittalyashu opened this issue Feb 22, 2021 · 0 comments
Labels

Comments

@mittalyashu
Copy link
Member

Currently, we are passing multiple arguments to the API helper functions.

for example

export const getPublicBoards = async (page = 1, limit, sort = "desc") => {
	return await axios({
		method: "GET",
		url: "/api/v1/boards",
		params: {
			page,
			limit,
			created: sort
		}
	});
};

👆 source code

As getPublicBoards function accept multiple arguments, due to confusion in which order the arguments needs to be passed, can lead to unexpected results.

In resolution of that problem, we can change the arguments to a single object.

for example

export const getPublicBoards = async ({ 
  page = 1,
  limit,
  sort = "desc"
}) => {
  return await axios({
    method: "GET",
    url: "/api/v1/boards",
    params: {
      page,
      limit,
      created: sort
    }
  });
}
@mittalyashu mittalyashu added the good first issue Good for newcomers label Feb 22, 2021
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

1 participant