Hi! Anybody knows how could http headers be sent o...
# webassembly
j
Hi! Anybody knows how could http headers be sent on a
window.fetch
call? I'm new to multiplatform and wasm, I see there's a second
init: RequesInit
parameter on the
fetch
call, but I'm not sure how should I pass a
mapOf<String, String>()
to this object which seems to require some wasm
JsAny?
type for
headers
. Of course, any other wasm ways/clients for http clients would also probably help me.
window.fetch
was just the only solution I found for this.
r
j
Thank you! I see you have a complete http client here for js & wasm. Nice! I tried to use just the essential parts and for some reason the backend service is still not receiving any header. I probably miss some silly thing. Here is a snippet of my code:
Copy code
val requestInit = obj<RequestInit> {}
        requestInit.headers = obj()
        requestInit.headers!!["key"] = "value".toJsString()
        window.fetch("<http://localhost:8136/account/v1/personal-accounts>", requestInit)
Will continue playing with this next week. Have a great day!