Search code examples
purescript

How do I get the current browser URL with purescript?


How do I get the the browser URL in Purescript, just like when doing window.location.href in javascript?


Solution

  • import Web.HTML (window)
    import Web.HTML.Window (location)
    import Web.HTML.Location (pathname)
    import Effect.Console (log)
    
    
    
    main :: Effect Unit
    main = do
      l <- window >>= location >>= pathname
      log $ l