aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/app/Api.hs
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2024-06-07 16:14:52 +0200
committerLibravatar Alexander Foremny <aforemny@posteo.de>2024-06-07 17:06:17 +0200
commit8a34cc822c2c508472fe29ab2be1b74ba06e59e6 (patch)
tree74a67b93a76addabdb0fcf9e9479f4c6f7b4d113 /frontend/app/Api.hs
parent79dd6af899fbaf7c413d7fd864f5716cbdf544e5 (diff)
add collections
Diffstat (limited to 'frontend/app/Api.hs')
-rw-r--r--frontend/app/Api.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/frontend/app/Api.hs b/frontend/app/Api.hs
index 2aa23c9..2b7598a 100644
--- a/frontend/app/Api.hs
+++ b/frontend/app/Api.hs
@@ -2,6 +2,7 @@
module Api
( fetchCollections,
+ createCollection,
fetchSchema,
fetchSchemaVersion,
fetchPosts,
@@ -33,6 +34,15 @@ fetchCollections :: JSM (Either String [String])
fetchCollections =
A.eitherDecode <$> fetch (fromString "http://localhost:8081/collections")
+createCollection :: String -> JSM (Either String ())
+createCollection collection =
+ A.eitherDecode
+ <$> fetch
+ ( fromString "http://localhost:8081/collections"
+ & setRequestMethod "POST"
+ & setRequestBodyLBS (A.encode (A.toJSON collection))
+ )
+
fetchSchemaVersion :: JSM (Either String Version)
fetchSchemaVersion =
A.eitherDecode <$> fetch (fromString "http://localhost:8081/schemaVersion")