​x
        [ button [ onClick MorePlease, style "display" "block" ] [ text "More Please!" ]
 
1
-- Press a button to send a GET request for random quotes.
2
--
3
-- Read how it works:
4
--   https://guide.elm-lang.org/effects/json.html
5
--
6
​
7
import Browser
8
import Html exposing (..)
9
import Html.Attributes exposing (style)
10
import Html.Events exposing (..)
11
import Http
12
import Json.Decode exposing (Decoder, map4, field, int, string)
13
​
14
​
15
​
16
-- MAIN
17
​
18
​
19
main =
20
  Browser.element
21
    { init = init
22
    , update = update
23
    , subscriptions = subscriptions
24
    , view = view
25
    }
26
​
27
​
28
​
29
-- MODEL
30
​
31
​
32
type Model
33
  = Failure
34
  | Loading
35
  | Success Quote
36
​
37
​
38
type alias Quote =
39
  { quote : String
40
  , source : String
41
  , author : String
42
  , year : Int
43
  }
44
​
45
​
46
init : () -> (Model, Cmd Msg)
47
init _ =
48
  (Loading, getRandomQuote)
49
​