Bromeon/js-sandbox

fetch api didnt work

ArunGust opened this issue · 1 comments

I tried to use fetch api, but didn't work

let js_code = r#"function triple(a) { fetch("https://reqbin.com/echo/get/json")
.then(response => response.json())
.then( json => return json)
.catch( error => return error) }"#;
let mut script = Script::from_string(js_code)?;

let arg = 7;
let result: String = script.call("triple", &arg)?;

print!("{:?}", result);
Ok(())

This is by design. The library is supposed to operate in a complete sandbox, i.e. without file and network access.

Obviously, using third-party libraries is a valid use case, and we have #2 for this. Unfortunately, at the moment I do not have the time to explore how this could be easily and securely enabled with Deno, so I'd appreciate any input on that issue! 🙂