jsonify : String -> Http.Body
jsonify str =
Http.jsonBody <| Encode.object [("sentiment", Encode.string str)]
decodeJson : Decode.Decoder String
decodeJson =
Decode.map2 (\classification status -> classification)
(Decode.field "classification" Decode.string)
(Decode.field "status" Decode.int)
fetchSentiment : String -> Cmd Msg
fetchSentiment sentiment =
Http.send Fetch (Http.post (jsonify sentiment) decodeJson)
fetchSentiment : String -> Cmd Msg
fetchSentiment sentiment = Http.send Fetch (postSentiment sentiment decodeJson)
postSentiment : String -> Decode.Decoder String -> Http.Request StringpostSentiment sentiment decoder = Http.request { method = "POST" , headers = [(Http.header "Content-Type" "application/json")] , url = "http://127.0.0.1:5000/sentiment" , body = (jsonify sentiment) , expect = Http.expectJson decoder , timeout = Nothing , withCredentials = False }
--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.