Programming Phoenix LiveView: Cannot Follow "The Promo Live View" Example

Hi, I am trying to follow along with the “The Promo Live View” example starting on Page 371 of the book. I am running into an error with the CSRF token. In googling it, I have found some discussions with numerous solutions, none of which seem to work. I thought, maybe it was best to come to the source and see if there is something that I overlooked or was excluded from the book. In trying to view the /promo route I am getting this error: no function clause matching in Plug.CSRFProtection.get_csrf_token_for/1 - any help would be greatly appreciated as I’m blocked in working through this part of the book. Thanks.

I’m glad you reached out! Can you share the version of LiveView you are using? Thanks!

Looking at the mix.lock file, version 0.15.4 is what got installed.

Hmm that should be just fine then, how odd. If you want to share a repo with your code in it, I’d be happy to pull it down and take a look.

Thanks for the reply. I ended up sorting the issue out. I’m not sure exactly what the problem was though. I copy-pasted the form html from the book into my editor; I ended up re-typing it from scratch and then everything was fine.

Glad to hear that you are un-blocked!

1 Like