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

♻️ Removing repetitive fetch functions #55

Open
astroash opened this issue Jun 10, 2018 · 1 comment
Open

♻️ Removing repetitive fetch functions #55

astroash opened this issue Jun 10, 2018 · 1 comment

Comments

@astroash
Copy link

export const getData = (url) => {
return fetch(url)
.then(checkResponse)
.catch((err) => {
throw new Error(`fetch getData failed ${err}`);
});
};
export const postData = (data) => {
return fetch('/match-court', { method: 'POST', body: data })
.then(checkResponse)
.catch((err) => {
throw new Error(`fetch getData failed ${err}`);
});
};

These two functions are very similar. You can add an options object argument to your first function and only need one fetch wrapping function.

@GiuliaTeggi
Copy link
Collaborator

Yes, this needs to be refactored, thank you! ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants