Skip to content

Instantly share code, notes, and snippets.

@willard1218
Created October 19, 2025 19:07
Show Gist options
  • Select an option

  • Save willard1218/16eb5c6920b9167f54324a543b3c861a to your computer and use it in GitHub Desktop.

Select an option

Save willard1218/16eb5c6920b9167f54324a543b3c861a to your computer and use it in GitHub Desktop.
dasfsfa
// response-body-is-freepreview.js
let body = $response.body;
if (body) {
try {
let obj = JSON.parse(body);
function setAllFreePreviewTrue(data) {
if (Array.isArray(data)) {
data.forEach(setAllFreePreviewTrue);
} else if (typeof data === "object" && data !== null) {
for (let key in data) {
if (key === "isFreePreview") {
data[key] = true;
} else {
setAllFreePreviewTrue(data[key]);
}
}
}
}
setAllFreePreviewTrue(obj);
body = JSON.stringify(obj);
} catch (e) {
console.log("JSON parse error:", e);
}
}
$done({ body });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment