Ajax.purs 630 Bytes
Newer Older
James Laver's avatar
James Laver committed
1 2 3 4 5 6 7 8 9 10
module Gargantext.Components.Search.Ajax where

import Prelude
import Effect.Class (liftEffect)
import Effect.Aff (Aff)
import Data.Argonaut (class DecodeJson)
import DOM.Simple.Console
import Gargantext.Types (toQuery)
import Gargantext.Components.Search.Types (SearchQuery)
import Gargantext.Config.REST (post)
Alexandre Delanoë's avatar
Alexandre Delanoë committed
11
import Gargantext.Config (urlPlease, End(Back))
James Laver's avatar
James Laver committed
12 13 14
import URI.Query as Q

searchUrl :: SearchQuery -> String
15
searchUrl q = urlPlease Back $ "new" <> Q.print (toQuery q)
James Laver's avatar
James Laver committed
16 17 18 19 20 21 22

search :: forall a. DecodeJson a => SearchQuery -> Aff a
search q = do
  let url = searchUrl q
  liftEffect $ log2 "url:" url
  post (searchUrl q) q