Skip to content

Update Readme for current usage #7

@salihguru

Description

@salihguru

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions