showing results for - "how to create an async function from a string in node js"
Alecia
06 Oct 2017
1// Shim for allowing async function creation via new Function
2const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor;
3
4// Usage
5const fetchPage = new AsyncFunction("url", "return await fetch(url);");
6fetchPage("/").then(response => { ... });
similar questions