Fork me on GitHub
Ben Lieberman00:02:55

Another noob Q: I have a handler fn that's making an API call and redirecting to /app . But when I click the button that dispatches this handler (the API call works and all), I am redirected to a version of /app that has multiple copies of the UI, that number depending on the number of times I've clicked the button. (I guess I should ask a question: what am I doing wrong?)

Epidiah Ravachol01:02:19

Are you using htmx on that button? If so, you might want to check out the swapping: The default behavior is innerHTML which places the new HTML it receives inside the element that made the call, which create a nested UI effect if you're receiving the whole webpage every time.

☝️ 1
Ben Lieberman01:02:39

I am so that almost definitely explains it. Thanks!

👍 1
🙌 1
Jacob O'Bryant05:02:34

in some situations the answer is to replace innerHTML with outerHTML, though in this case it sounds like you might want to just do a regular form that posts to your endpoint without htmx.

Jacob O'Bryant06:02:45

I.e. if you want to refresh the whole page or navigate to a new page, then no need for htmx. but htmx is handy if you want to do some kind of "small" interaction where reloading the page would be overkill/degrade the experience. e.g. I use htmx for the like + dislike buttons in the app I work on.

Michael W22:02:05

I am jacked into the nrepl server started by biff. I am trying to figure out how to use the secrets, I tried this and it failed at the repl: ((:biff/secret @biff/system) :cookie/secret) In secrets.env COOKIE_SECRET=randomstring is set.

Jacob O'Bryant22:02:43

First thing to check is if config.edn contains a key called :cookie/secret. The key added by default is called :biff.middleware/cookie-secret, so that may be your problem. Are you expecting that Biff takes :cookie/secret and infers that the env var for it should be COOKIE_SECRET? That might be a point of confusion. Biff uses the :cookie/secret key to check config.edn for the name of an environment variable, and then returns the value of that env var.

Michael W22:02:21

Ahh so I have to add a secret to secrets.edn and a pointer for that secret into config.edn?

Jacob O'Bryant22:02:39

Yep. (though secrets.env, not secrets.edn)

Michael W22:02:15

Yeah, just have edn on the brain. Thanks, that's enough for me to get to the next roadblock. Having much fun with biff.

Jacob O'Bryant22:02:01

Excellent, glad you're enjoying it!