Using fetch() for HTTP requests?

108 views
Skip to first unread message

Nv7

unread,
Jan 11, 2021, 6:49:07 PM1/11/21
to golang-nuts

I am making a WebAssembly app with Go. Currently, it is 8.1MB uncompressed and 2MB gzipped. This is too much. I want to use TinyGo, but I need to send HTTP GET requests. TinyGo currently doesn't support net/http. But, TinyGo has syscall/js which allows you to do fetch(). But I couldn't find out how to use JS await using syscall/js. I also tried using channels from handlers and returning the value of channels, but this gave me fatal error: All goroutines are asleep. Deadlock!.

Are there any alternatives for net/http that work with tinygo or ways to use fetch and return values instead of having callbacks?

Reply all
Reply to author
Forward
0 new messages