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

Update Readme for current usage #7

Open
9ssi7 opened this issue Jan 22, 2023 · 0 comments
Open

Update Readme for current usage #7

9ssi7 opened this issue Jan 22, 2023 · 0 comments

Comments

@9ssi7
Copy link

9ssi7 commented Jan 22, 2023

Is your feature request related to a problem? Please describe.
Yes, it's about an issue. I was going to use fetchp for the first time today and I wanted to use it as reactive in a react project.

Describe the solution you'd like
In the example there was a usage like:

import { useFetchp } from "fetchp";

const MyComponent = (props) => {
  const { data, isLoading, error } = useFetchp("GET", "/posts");

  if (isLoading) {
    return <div>Loading...</div>;
  }

  if (error) {
    return <div>Error: {error.message}</div>;
  }

  return <div>{JSON.stringify(data)}</div>;
};

But isLoading doesn't actually work as expected. isFetching meets the expectations of isLoading. So when I updated as below, the problem did not occur.

import { useFetchp } from "fetchp";

const MyComponent = (props) => {
  const { data, isFetching, error, doFetch } = useFetchp("GET", "/posts");

  useEffect(() => {
		  doFetch()
	  }, [])

  if (isFetching) {
    return <div>Loading...</div>;
  }

  if (error) {
    return <div>Error: {error.message}</div>;
  }

  return <div>{JSON.stringify(data)}</div>;
};

Also, no example is given for POST request. I was able to learn how to send parameters by examining the codes.

Describe alternatives you've considered

  • POST request usage example can be added.
  • Current usage should be added for React usage, it doesn't work when copying in Readme.

If we don't want the README to be long, we can at least prepare a documentation.

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

1 participant