Rust example for the fetch API?

I am having some troubles using the the fetch API from code written in Rust. Is there any example on how to fetch an URL using Rust code compiled to WASM?

If you’ve used the reqwest HTTP client library before - good news! you can now use reqwest from inside a worker!. (as of v0.10.9). One place you can find sample code is in the crate service-logging, which I wrote to do logging from inside CF workers. Logs are sent over https (using reqwest library) to Coralogix. One useful trick for logging is that you can use the event.waitUntil function to send logs after the response has been returned to the client; avoiding the round-trip http call provides a remarkable performance improvement!

Thanks a lot! reqwest seems to works just fine. I’ll take a look at Coralogix and may use your crate, but I am not sure yet how to do logging for my worker.

In wasm-service and the associated rustwasm-service-template - there’s sample code that shows how to do logging from a worker using Coralogix.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.