Commit aab569f8 authored by Abinaya Sudhir's avatar Abinaya Sudhir

Added Api code

parent e1475f43
......@@ -9,6 +9,7 @@ import Control.Monad.Eff.Class (liftEff)
import Control.Monad.Eff.Console (CONSOLE)
import DOM (DOM)
import DOM.HTML (window)
import DOM.HTML.Location (host)
import DOM.HTML.Window (localStorage)
import DOM.WebStorage.Storage (getItem, setItem)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, jsonEmptyObject, (.?), (:=), (~>))
......@@ -19,7 +20,7 @@ import Data.MediaType.Common (applicationJSON)
import Network.HTTP.Affjax (AJAX, affjax, defaultRequest)
import Network.HTTP.RequestHeader (RequestHeader(..))
import Prelude hiding (div)
import React.DOM (a, button, div, form, h2, h3, h4, i, input, label, p, span, text)
import React.DOM (a, button, div, form, h2, h3, h4, i, input, label, li, p, span, text, ul)
import React.DOM.Props (_id, _type, className, href, maxLength, name, onClick, onInput, placeholder, target, value)
import Routing.Hash.Aff (setHash)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
......@@ -76,9 +77,62 @@ addcorpusviewSpec = simpleSpec performAction render
, div [className "col-md-9"]
[
h3 [] [text "Corpusview"]
, ul [className "list-group"]
[
li [className "list-group-item justify-content-between"]
[
span [className "badge badge-default badge-pill"] []
]
]
]
]
]
]
]
getDatabaseDetais = do
let token = ""
-- liftEff $ log $ "calling update Age "
affResp <- liftAff $ attempt $ affjax defaultRequest
{ method = Left GET
, url ="http://unstable.gargantext.org/api/auth/token"
, headers = [ ContentType applicationJSON
, Accept applicationJSON
, RequestHeader "Authorization" $ "Bearer " <> token
]
}
case affResp of
Left err -> do
pure $ Left $ show err
Right a -> do
liftAff $ log $ "POST method Completed"
liftAff $ log $ "GET /api response: " <> show a.response
let res = decodeJson a.response
pure res
-- updateProfileAge :: forall eff. State -> UpdateAgeReq -> Aff (console::CONSOLE,ajax :: AJAX | eff) (Either String UpdateProfileUserProfile)
-- updateProfileAge state reqBody = do
-- let token = fromMaybe "" $ (\(State s) -> s.token) state
-- liftEff $ log $ "calling update Age " <> show reqBody
-- affResp <- liftAff $ attempt $ affjax defaultRequest
-- { method = Left PUT
-- , url = host <> "api/users/update_profile_fields"
-- , headers = [ ContentType applicationJSON
-- , Accept applicationJSON
-- , RequestHeader "Authorization" $ "Bearer " <> token
-- ]
-- , content = Just $ encodeJson reqBody
-- }
-- case affResp of
-- Left err -> do
-- pure $ Left $ show err
-- Right a -> do
-- liftEff $ log $ "POST method Completed"
-- liftEff $ log $ "GET /api response: " <> show a.response
-- let res = decodeJson a.response
-- pure res
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