Answers for "how to create an async function from a string in node js"

0

how to create an async function from a string in node js

// Shim for allowing async function creation via new Function
const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor;

// Usage
const fetchPage = new AsyncFunction("url", "return await fetch(url);");
fetchPage("/").then(response => { ... });
Posted by: Guest on September-27-2021

Code answers related to "how to create an async function from a string in node js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language