async-fetch 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/useAsyncFetch.js +4 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "async-fetch",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "Use fetch asynchronously for requests within React components.",
5
5
  "main": "useAsyncFetch.js",
6
6
  "type": "module",
package/useAsyncFetch.js CHANGED
@@ -43,7 +43,7 @@ function useAsyncFetch(path, props = {}) {
43
43
  }, []);
44
44
 
45
45
  useEffect(() => {
46
- sendRequest();
46
+ sendRequest("USE_CACHE");
47
47
  }, [path, ...deps]);
48
48
 
49
49
  useInterval(() => {
@@ -61,7 +61,7 @@ function useAsyncFetch(path, props = {}) {
61
61
  }
62
62
  }
63
63
 
64
- async function sendRequest() {
64
+ async function sendRequest(constant) {
65
65
  if (!path) throw new Error("URL is required.");
66
66
 
67
67
  if (typeof path !== "string")
@@ -106,7 +106,8 @@ function useAsyncFetch(path, props = {}) {
106
106
 
107
107
  const url = path + q;
108
108
 
109
- const cachedResponse = cache.get(url, fetchProps);
109
+ const cachedResponse =
110
+ constant === "USE_CACHE" && cache.get(url, fetchProps);
110
111
 
111
112
  let parsedResponse = cachedResponse;
112
113