Skip to content

Instantly share code, notes, and snippets.

@blakek
Created April 10, 2023 19:14
Show Gist options
  • Save blakek/778980c6c8d139bf38c1e646945ab98a to your computer and use it in GitHub Desktop.
Save blakek/778980c6c8d139bf38c1e646945ab98a to your computer and use it in GitHub Desktop.
Run basic external code from a Zapier code step
async function importURL(url) {
const vm = require("vm");
const res = await fetch(url).then((r) => r.text());
return vm.runInThisContext(res, { filename: url });
}
// Example usage:
//
// await importURL(
// "https://gist.githubusercontent.com/blakek/660a8881ae56641d8804971b848df17e/raw/0fb0ec0646d5c8dc353dd9dadc9f5d8ccb7821b2/queryStringParse.js"
// );
//
// return queryStringParse("q=this%20is%20a%20test");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment