From 8a34cc822c2c508472fe29ab2be1b74ba06e59e6 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Fri, 7 Jun 2024 16:14:52 +0200 Subject: add collections --- frontend/app/Api.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'frontend/app/Api.hs') 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") -- cgit v1.2.3