We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#535
I am currently using ethers and using it in v8, but ethers will use fetch
How to implement fetch in C # when accessing the network
using var engine = new V8ScriptEngine(V8ScriptEngineFlags.EnableTaskPromiseConversion); engine.AddHostObject("fetch", Response.fetch); public sealed class Response { private string _html; public Task<string> text() => Task.FromResult(_html); public static async Task<Response> fetch(string url, IScriptObject obj = null){ if (obj != null) ............... using var client = new HttpClient(); return new Response { _html = await client.GetStringAsync(url) }; } }
I added a method, but JavaScript cannot recognize this object
public Task<object> json() { var jsonObject = Newtonsoft.Json.JsonConvert.DeserializeObject(_html); return Task.FromResult(jsonObject); }
The text was updated successfully, but these errors were encountered:
Hi @kissxrl,
Try something like this:
public Task<object> json() => Task.FromResult<object>(ScriptEngine.Current.Script.JSON.parse(_html));
Good luck!
Sorry, something went wrong.
Please reopen this issue if you have additional thoughts or questions about this topic. Thanks!
ClearScriptLib
No branches or pull requests
#535
I am currently using ethers and using it in v8, but ethers will use fetch
How to implement fetch in C # when accessing the network
I added a method, but JavaScript cannot recognize this object
The text was updated successfully, but these errors were encountered: