I’m just starting out with purescript trying to write a simple purescript frontend to a Haskell backend, and am having issues getting them to communicate. I’m using purescript-payload, and I can communicate to the server just fine in the REPL, but as soon as I try to call it within my handleAction function I only get RequestError: { message: "There was a problem making the request: request failed" }. I’m not sure if I’m actually understanding where the error is coming from, but I was hoping someone who has some more experience might have some insight, or a minimal example of using a Halogen frontend with payload to see if I’m doing something obviously wrong.
I’m still struggling a little with why there’s a distinction between Aff and Effect, and thought maybe I need to do things differently when querying web APIs. My minimal example does things in a fairly synchronous manner at the moment.
Okay so I did figure out the issue. It was due to the fact that my server (and also Google in the minimal example) both didn’t have the Access-Control-Allow-Origin header set up to allow their content to be displayed on arbitrary web pages, which the console version didn’t care about, but the browser did. So not really a Halogen issue specifically so much as due to viewing the page in the browser.
Yeah, I had the same issue today, I put the middleware in the Haskell backend to properly respond to all preflight OPTION requests properly and to set Access-Control-Allow-Origin: * in the actual GET/POST responses when necessary.