@studiocms/cfetch 0.1.1 → 0.1.2

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/README.md +11 -11
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -60,7 +60,7 @@ export default defineConfig({
60
60
 
61
61
  ### Usage
62
62
 
63
- You can import the cachedFetch function anywhere you would use a normal `fetch` call. `cfetch` adapts the same default options as fetch,
63
+ You can import the `cFetch` function anywhere and use it as you would use a normal `fetch` call. `cFetch` adapts the same default options as `fetch`:
64
64
 
65
65
  ```astro
66
66
  ---
@@ -70,29 +70,29 @@ const response = await cFetch(
70
70
  'https://example.com', // string | URL | Request
71
71
  { /* Normal fetch init optional options here, method, mode, etc. */ },
72
72
  { lifetime: "1h" } // Optional, allows changing the default lifetime of the cache
73
- );
73
+ );
74
74
 
75
75
  const html = await response.text();
76
76
  ---
77
77
  ```
78
78
 
79
- If you are also wanting the other available metadata (such as `lastChecked` value which is the last time the cache was updated) then you can add the following prop to cached fetch, changing the shape of the data output to the following:
79
+ If you need to access the other available metadata (such as the `lastChecked` value which provides the last time the cache was updated), you can pass `true` as the fourth parameter, which will change the returned object to the following:
80
80
 
81
81
  ```astro
82
82
  ---
83
83
  import { cFetch } from 'c:fetch';
84
84
 
85
- const { lastCheck, data: response } = await cFetch(
86
- 'https://example.com', // string | URL | Request
87
- { /* Normal fetch init optional options here, method, mode, etc. */ },
88
- { lifetime: "1h" }, // Optional, allows changing the default lifetime of the cache
89
- true
90
- );
85
+ const { lastCheck, data } = await cFetch(
86
+ 'https://example.com',
87
+ { /* ... */ },
88
+ { lifetime: "1h" },
89
+ true // Changes the the output to include the lastCheck value
90
+ );
91
91
 
92
- const html = await response.text();
92
+ const html = await data.text();
93
93
  ---
94
94
  ```
95
95
 
96
96
  ## Licensing
97
97
 
98
- [MIT Licensed](https://github.com/withstudiocms/cfetch/blob/main/LICENSE).
98
+ [MIT Licensed](https://github.com/withstudiocms/cfetch/blob/main/LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studiocms/cfetch",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Astro integration that allows you to have a cached fetch function in your Astro SSR project.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://studiocms.dev",