How to refresh a Page in Phoenix?

Suppose, I have a page and some error has occurred(error like- can’t fetch data from DB) and now I want to refresh a page. How can I do that? Your reply will be highly appreciated.

Hit F5 on your keyboard… Thats how refreshing the page in most browsers work.

If though you want to have phoenix tell the client to reload some data on certain events, you should look into channels.

Also then I wouldn’t send the command to reload, but I’d send the additional data instead…

Not 100% sure what exactly you need, but maybe in case of an error you could use redirect/2?
https://hexdocs.pm/phoenix/Phoenix.Controller.html#redirect/2

2 Likes

Thanks bro.