mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-24 15:12:01 +03:00
Remove obsolete Fetcher prototype functions and replace with new one.
This commit is contained in:
parent
5b9fd32a7c
commit
54b6891938
@ -54,7 +54,7 @@ init :
|
||||
-> ( Model, Effect Msg )
|
||||
init maybePageUrl sharedModel static =
|
||||
( {}
|
||||
, Fetcher.Signup.something GotResponse
|
||||
, Fetcher.Signup.submit GotResponse
|
||||
{ headers = []
|
||||
, fields =
|
||||
[ ( "first", "Jane" )
|
||||
|
@ -1298,61 +1298,18 @@ function fetcherModule(name) {
|
||||
})
|
||||
.join(", ");
|
||||
|
||||
return `module Fetcher.${moduleName} exposing (load, submit, something)
|
||||
return `module Fetcher.${moduleName} exposing (submit)
|
||||
|
||||
{-| -}
|
||||
|
||||
import Bytes exposing (Bytes)
|
||||
import Bytes.Decode
|
||||
import Effect exposing (Effect)
|
||||
import FormDecoder
|
||||
import Http
|
||||
import Route.${moduleName}
|
||||
|
||||
|
||||
{-| -}
|
||||
load : Effect (Result Http.Error Route.${moduleName}.Data)
|
||||
load =
|
||||
Http.request
|
||||
{ expect = Http.expectBytes identity Route.${moduleName}.w3_decode_Data
|
||||
, tracker = Nothing
|
||||
, body = Http.emptyBody
|
||||
, headers = []
|
||||
, url = [ ${fetcherPath} ] |> List.concat |> String.join "/"
|
||||
, method = "GET"
|
||||
, timeout = Nothing
|
||||
}
|
||||
|> Effect.fromCmd
|
||||
|
||||
|
||||
{-| -}
|
||||
submit :
|
||||
{ headers : List ( String, String )
|
||||
, formFields : List ( String, String )
|
||||
}
|
||||
-> Effect (Result Http.Error Route.${moduleName}.ActionData)
|
||||
submit options =
|
||||
let
|
||||
{ contentType, body } =
|
||||
FormDecoder.encodeFormData options.formFields
|
||||
in
|
||||
Http.request
|
||||
{ expect = Http.expectBytes identity Route.${moduleName}.w3_decode_ActionData
|
||||
, tracker = Nothing
|
||||
, body = Http.stringBody contentType body
|
||||
, headers = options.headers |> List.map (\\( key, value ) -> Http.header key value)
|
||||
, url = ${
|
||||
fetcherPath === ""
|
||||
? '"/content.dat"'
|
||||
: `[ ${fetcherPath}, [ "content.dat" ] ] |> List.concat |> String.join "/"`
|
||||
}
|
||||
, method = "POST"
|
||||
, timeout = Nothing
|
||||
}
|
||||
|> Effect.fromCmd
|
||||
|
||||
|
||||
something :
|
||||
(Result Http.Error Route.${moduleName}.ActionData -> msg)
|
||||
->
|
||||
{ fields : List ( String, String )
|
||||
@ -1364,7 +1321,7 @@ something :
|
||||
, headers : List ( String, String )
|
||||
, url : Maybe String
|
||||
}
|
||||
something toMsg options =
|
||||
submit toMsg options =
|
||||
{ decoder =
|
||||
\\bytesResult ->
|
||||
bytesResult
|
||||
|
Loading…
Reference in New Issue
Block a user