Skip to content

Instantly share code, notes, and snippets.

@wplit
Last active March 30, 2025 00:13
Show Gist options
  • Save wplit/c47502017f8fff4226045b57f22682c8 to your computer and use it in GitHub Desktop.
Save wplit/c47502017f8fff4226045b57f22682c8 to your computer and use it in GitHub Desktop.
wpgb bricks addon
/* current code, fails when fails when t.body is undefined */
request: function (e, t) {
const { body: n } = t; // This fails when t.body is undefined
r = JSON.parse(n);
return "bricks_render_element" === r?.action && r?.element && (m(r.element), E(r.element.id)), [e, t];
}
// Possible solution, returns original request if no body
request: function (e, t) {
if (t && t.body) {
const { body: n } = t;
r = JSON.parse(n);
return "bricks_render_element" === r?.action && r?.element && (m(r.element), E(r.element.id)), [e, t];
}
return [e, t];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment