Specifying Http headers in Elm -
my elm program works fine code (excerpt) below using http.get
, had changed custom request specify jwt in header, , following error due type mismatch.
i think need change type of request
http.request (list qfields)
not sure how to. apparently, can't make { verb = "get" ...} decoder
because { verb ... }
not function.
the 2nd argument function `send` causing mismatch. 264| http.send fetchhntopstories request ^^^^^^^ function `send` expecting 2nd argument be: http.request (list qfields) is: request
<working code> request : http.request (list qfields) request = let decoder = jd.at [ "data", "qqry" ] <| jd.list qdecoder in http.get ("http://localhost:3000/graphql?query=" ++ encoded) decoder type msg = sendmessage | fetchhntopstories (result http.error (list qfields)) ... initmodel : taco -> ( model, cmd msg ) initmodel taco = let startmodel = { newmessage = "" } cmd = http.send fetchhntopstories request in ( startmodel ! [cmd] )
<changed code - not working> request : request request = let decoder = jd.at [ "data", "qry" ] <| jd.list qdecoder headers= [ ("authorization","bearer eyjhbgcioijiuzuxm...kv6tgw7h1gx2g") ] in { verb = "get" , headers = headers , url = url , body = http.emptybody , expect = http.expectjson decoder }
if understand correctly, need use http.request
, instead of http.get
, , supply valid record, this:
request : http.request (list qfields) request = let decoder = jd.at [ "data", "qry" ] <| jd.list qdecoder headers= [ ("authorization","bearer eyjhbgcioijiuzuxm...kv6tgw7h1gx2g") ] in http.request -- line missing code { method = "get" , headers = headers , url = url , body = http.emptybody , expect = http.expectjson decoder }
Comments
Post a Comment