Programming Phoenix LiveView: Chapter 4- Mount and Render the Product Index

Please use the following format for the title of this thread (then simply delete/replace this text with the content for the thread):

Title: Programming Phoenix LiveView: B7.0 Chapter 4- Mount and Render the Product Index

​ ​def​ mount(_params, _session, socket) ​do
​ {​*:ok​,
​ socket
​ > assign(​
:greeting​, ​"​​Welcome to Pento!"​) ​# add this line
​ > assign(​
:products*​, list_products())}
​ ​end

This call to the Phoenix.Socket.assign/3 function adds a key/value pair to the socket struct’s map of :assigns.

Please double check, I think it is Phoenix.LiveView.assign/3 function instead.

1 Like