We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
fetch
1 parent 96d84d2 commit 9eb4a90Copy full SHA for 9eb4a90
README.md
@@ -42,13 +42,25 @@ const result3 = await neval(
42
`,
43
{
44
context: {
45
- sleep: async (ms) => {
+ sleep: async (ms: number) => {
46
return new Promise((resolve) => setTimeout(resolve, ms));
47
},
48
49
}
50
);
51
console.log(result3); // Result after 1 second is 2
52
+
53
+const result4 = await neval(
54
+ `
55
+ fetch('https://example.com', { method: 'HEAD' })
56
+ .then((resp) => resp.statusText);
57
+`,
58
+ {
59
+ // By default, the "fetch" API is not available, you must add it to the context
60
+ context: { fetch },
61
+ }
62
+);
63
+console.log(result4); // OK
64
```
65
66
Importing `neval/register` will register the `neval` function on the global object and overrides the `eval` function.
0 commit comments