``` val response = window.fetch(url, object: Re...
# javascript
a
Copy code
val response = window.fetch(url, object: RequestInit {
        override var method: String? = method
        override var body: dynamic = body
        override var credentials: RequestCredentials? = RequestCredentials.Companion.INCLUDE
        override var cache: RequestCache? = RequestCache.Companion.NO_CACHE
        override var mode: RequestMode? = RequestMode.Companion.NO_CORS
        override var headers: dynamic = json("Accept" to "application/json")
      }).await()
this is so weird, i can set Accept in the header just fine, but when I try and set another header value, it doesn't come thru
b
aa: what did you mean? do you try to write
override var headers
twice?
a
like
override var headers: dynamic = json("User-Id" to "ewfwefwe")
User-Id is custom header I need for my server's auth
but after I set it either by itself or in same json as Accepts it just isn't there. Something is limiting the headers to just certain keys
and User-Id isn't one of them
b
could you show self contain example?
override var headers: dynamic = json("Accept" to "application/json", "Anything" to "blah")
chrome dev tools shows all headers in responce
a
hmmmm plot thickens! thanks I will investigate more what's different about the example I'm using. Maybe it's the await call?
b
I don’t think so
await
just waits returned Promise
a
where would u look next? When I do AAAA and CCCC tests they just aren't there
b
do you play with
kotlin-fullstack-sample
or with your own code?
a
my own code is 99% same as fullstack sample at this point but good point. I'll go back to their code and see if problem there too
b
How do you check what headers was not sent?
a
Copy code
require 'socket'
s = TCPServer.new 8080

loop do
    c = s.accept    # Wait for a client to connect
    while line = c.gets # Read lines from socket
        puts line         # and print them
    end
end
running that little server
k
Did you try to look at "network" tab in your browser's dev tools?
b
I’d see to the browser internal tools
k
Did you try to debug the code? What object is actually sent to
fetch
method?
a
ahh, i see the line that causes it now: override var mode: RequestMode? = RequestMode.Companion.NO_CORS
this is a NO_CORS issue
b
yes, with no-cors I don’t see other headers, and looks like it’s expected behaviour https://developer.mozilla.org/en-US/docs/Web/API/Request/mode
a
thanks i'll close ticket and find away around no_cors
b
And please write comment before close
a