add collections

This commit is contained in:
Alexander Foremny
2024-06-07 16:14:52 +02:00
parent 79dd6af899
commit 8a34cc822c
5 changed files with 74 additions and 46 deletions

View File

@@ -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")