diff options
author | Alexander Foremny <aforemny@posteo.de> | 2024-06-07 16:14:52 +0200 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2024-06-07 17:06:17 +0200 |
commit | 8a34cc822c2c508472fe29ab2be1b74ba06e59e6 (patch) | |
tree | 74a67b93a76addabdb0fcf9e9479f4c6f7b4d113 /frontend/app/Api.hs | |
parent | 79dd6af899fbaf7c413d7fd864f5716cbdf544e5 (diff) |
add collections
Diffstat (limited to 'frontend/app/Api.hs')
-rw-r--r-- | frontend/app/Api.hs | 10 |
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") |