We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
header "" "something"
headers
module Main exposing (main) import Browser import Html exposing (Html, button, div, text) import Html.Events exposing (onClick) import Http type alias Model = {} init : () -> ( Model, Cmd Msg ) init _ = ( {} , Http.request { method = "GET" , headers = [ Http.header "" "something" ] , url = "https://www.example.com" , body = Http.emptyBody , expect = Http.expectWhatever (always NoOp) , timeout = Nothing , tracker = Nothing } ) type Msg = NoOp update : Msg -> Model -> ( Model, Cmd Msg ) update msg model = case msg of NoOp -> ( model, Cmd.none ) view : Model -> Html Msg view model = div [] [] main : Program () Model Msg main = Browser.element { init = init , view = view , update = update , subscriptions = always Sub.none }
Uncaught SyntaxError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': '' is not a valid HTTP header field name.
On the other hand, empty "value" does not cause exception.
What I actually wanted was, conditionally adding/not adding a Http.header based on a variable like so:
Http.header
... , headers = [ case fooBar of Foo str -> Http.header "foo" str Bar -> Http.header "" "" , ... ] ...
but as it turned out it ends up in a runtime exception.
Http.header "" "something"
setRequestHeader()
none
The latter could be useful since it can be used paired with if or case inside Lists, like I wanted to do.
if
case
As for my intent, for now we can just wrap it in a List for the same effect:
... , headers = case fooBar of Foo str -> [ Http.header "foo" str ] Bar -> [] , ... ] ...
The text was updated successfully, but these errors were encountered:
Http.header ""
No branches or pull requests
Steps to reproduce:
header "" "something"
inheaders
list for any Http requestResult (runtime exception)
On the other hand, empty "value" does not cause exception.
Expected behavior/Proposal
What I actually wanted was, conditionally adding/not adding a
Http.header
based on a variable like so:but as it turned out it ends up in a runtime exception.
Http.header "" "something"
should either:setRequestHeader()
at runtime (effectivelynone
for header)The latter could be useful since it can be used paired with
if
orcase
inside Lists, like I wanted to do.As for my intent, for now we can just wrap it in a List for the same effect:
The text was updated successfully, but these errors were encountered: