Created
October 19, 2025 19:07
-
-
Save willard1218/16eb5c6920b9167f54324a543b3c861a to your computer and use it in GitHub Desktop.
dasfsfa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment