ilyalesik/react-fetch-hook

What are specialOptions for?

syabro opened this issue · 2 comments

It's only mentioned in https://github.com/ilyalesik/react-fetch-hook#usefetch
and it's duplicating regular options

It's just for convenience. As an example, we can have function that returns params for fetch function:

export const getSomeData = (options) => {
    const { token } = options;
    return [
        url,
        {
          headers: {
            Authorization: `JWT ${token}`
         }
       }
    ];
};

and destructure result of this function to useFetch arguments:

     const result = useFetch(
        ...getSomeData({
            token
        }),
        {
            depends: [something]
        }
    )

ty