Commit a849f70e authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch '80-dev-frontend-errors' of...

Merge branch '80-dev-frontend-errors' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev
parents e1c55df0 2574713c
......@@ -65,11 +65,6 @@ readJSON affResp =
Left err -> Left $ ReadJSONError err
Right r -> Right r
-- readJSONOrFail affResp = do
-- case readJSON affResp of
-- Left err -> throwError $ error $ "decodeJson affResp.body: " <> show err
-- Right b -> pure b
-- TODO too much duplicate code in `postWwwUrlencoded`
send :: forall body res. JSON.WriteForeign body => JSON.ReadForeign res =>
Method -> Maybe Token -> String -> Maybe body -> Aff (Either RESTError res)
......
module Gargantext.Utils.CacheAPI where
import Gargantext.Prelude hiding (add)
import Control.Monad.Except (runExcept)
import Control.Promise (Promise, toAffE)
import Data.Either (Either(..))
......@@ -10,25 +12,12 @@ import Effect.Aff (Aff, throwError)
import Effect.Exception (error)
import Foreign as F
import Foreign.Object as O
import Gargantext.Ends (class ToUrl, toUrl)
import Gargantext.Sessions (Session(..))
import Milkis as M
import Simple.JSON as JSON
import Type.Row (class Union)
import Gargantext.Prelude hiding (add)
import Gargantext.Ends (class ToUrl, toUrl)
import Gargantext.Sessions (Session(..))
get :: forall a p. JSON.ReadForeign a => ToUrl Session p => Cache -> Session -> p -> Aff a
get cache session p = do
let req = makeGetRequest session p
res <- cached cache req
j <- M.text res
case JSON.readJSON j of
Left err -> throwError $ error $ "decodeJson affResp.body: " <> show err
Right b -> pure b
foreign import data Cache :: Type
foreign import data Request :: Type
......@@ -119,7 +108,7 @@ pureJson req = do
Right b -> pure b
foreign import _makeRequest :: forall options trash.
foreign import _makeRequest :: forall options.
M.URL -> { method :: M.Method, headers :: M.Headers | options } -> Request
foreign import _openCache :: String -> Effect (Promise Cache)
foreign import _delete :: String -> Effect (Promise Unit)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment