Title
a

aa

07/10/2017, 3:50 PM
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

bashor

07/10/2017, 4:13 PM
aa: what did you mean? do you try to write
override var headers
twice?
a

aa

07/10/2017, 4:14 PM
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

bashor

07/10/2017, 4:16 PM
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

aa

07/10/2017, 4:37 PM
hmmmm plot thickens! thanks I will investigate more what's different about the example I'm using. Maybe it's the await call?
b

bashor

07/10/2017, 4:37 PM
I don’t think so
await
just waits returned Promise
a

aa

07/10/2017, 4:38 PM
where would u look next? When I do AAAA and CCCC tests they just aren't there
b

bashor

07/10/2017, 4:39 PM
do you play with
kotlin-fullstack-sample
or with your own code?
a

aa

07/10/2017, 4:40 PM
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

bashor

07/10/2017, 4:41 PM
How do you check what headers was not sent?
a

aa

07/10/2017, 4:41 PM
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

konsoletyper

07/10/2017, 4:42 PM
Did you try to look at "network" tab in your browser's dev tools?
b

bashor

07/10/2017, 4:42 PM
I’d see to the browser internal tools
k

konsoletyper

07/10/2017, 4:42 PM
Did you try to debug the code? What object is actually sent to
fetch
method?
a

aa

07/10/2017, 4:44 PM
ahh, i see the line that causes it now: override var mode: RequestMode? = RequestMode.Companion.NO_CORS
this is a NO_CORS issue
b

bashor

07/10/2017, 4:49 PM
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

aa

07/10/2017, 4:50 PM
thanks i'll close ticket and find away around no_cors
b

bashor

07/10/2017, 4:51 PM
And please write comment before close
a

aa

07/10/2017, 4:52 PM