You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importPreludeimportControl.Monad.Eff (Eff())
importControl.Monad.Eff.Console (CONSOLE(), log)
importControl.Monad.Eff.ExceptionimportControl.Monad.Affimport qualified Network.HTTP.AffjaxasAimportNetwork.HTTP.Affjax.RequestimportNetwork.HTTP.Affjax.ResponseimportNetwork.HTTP.MethodimportNetwork.HTTP.RequestHeaderimportBrowser.WebStorageimportData.MaybeimportData.EitherimportData.Either.Unsafemain::foralle. Eff_Unit
main = do
runAff throwException log fetchCurrentAuth
fetchCurrentAuth::foralleff. Aff_String
fetchCurrentAuth = do
token <- liftEff' $ getItem localStorage "Authorization"let tok = fromMaybe "" $ fromRight token
let request = A.defaultRequest
{ url = "url"
, method = GET
, headers =
[ RequestHeader"Content-Type""application/json"
, RequestHeader"Accept""application/json"
, RequestHeader"Authorization" tok
]
}
result <-A.affjax request ::A.Affjax_String
return $ tok <> result.response
The problem ended up being that my token from localStorage had a \n on the end of it and when debugging the outputted js I was getting this error Failed to execute 'setRequestHeader' on 'XMLHttpRequest' […] is not a valid HTTP header field value that affjax is not catching.
The text was updated successfully, but these errors were encountered:
codedmart
added a commit
to codedmart/purescript-affjax
that referenced
this issue
Jan 27, 2016
I had the following code:
The problem ended up being that my token from localStorage had a
\n
on the end of it and when debugging the outputted js I was getting this errorFailed to execute 'setRequestHeader' on 'XMLHttpRequest' […] is not a valid HTTP header field value
that affjax is not catching.The text was updated successfully, but these errors were encountered: