forked from hoodunit/purescript-payload
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Client.purs
18 lines (15 loc) · 669 Bytes
/
Client.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Payload.Examples.Basic.Client where
import Prelude
import Effect (Effect)
import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Effect.Console (log)
import Payload.Client (defaultOpts, mkGuardedClient, unwrapBody)
import Payload.Examples.Basic.Spec (spec)
main :: Effect Unit
main = launchAff_ do
let client = mkGuardedClient (defaultOpts { baseUrl = "http://localhost:3000" }) spec
existingUser <- unwrapBody (client.users.byId.get {params: {id: 1}})
newUser <- unwrapBody (client.adminUsers.create {body: {id: 2, name: "whodunnit"}})
liftEffect $ log $ "Existing: " <> show existingUser
liftEffect $ log $ "New: " <> show newUser