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

docs: fix caching example by using .clone() method #218

Merged
merged 2 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/custom-caching/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ const client = prismic.createClient(endpoint, {

if (cache.has(key)) {
// If the cache contains a value for the key, return it
return cache.get(key);
return cache.get(key).clone();
} else {
// Otherwise, make the network request
const res = await fetch(url, options);

if (res.ok) {
// If the request was successful, save it to the cache
cache.set(key, res);
cache.set(key, res.clone());
}

return res;
Expand Down
4 changes: 2 additions & 2 deletions examples/with-express/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ const client = prismic.createClient(endpoint, {

if (cache.has(key)) {
// If the cache contains a value for the key, return it
return cache.get(key);
return cache.get(key).clone();
} else {
// Otherwise, make the network request
const res = await fetch(url, options);

if (res.ok) {
// If the request was successful, save it to the cache
cache.set(key, res);
cache.set(key, res.clone());
}

return res;
Expand Down