How to call a function onclick from view

Hi all,
I’m pretty new to adonis and I’m struggling to find how to call a function (ideally from my controller) on button click in my view?

Hey @Grimfinn! :wave:

I believe you are mixing frontend runtime and backend runtime.

Adonis ran in the backend. What you are asking is to listen to a frontend event, which is not doable on Adonis.

There’s multiple solution for that:

  1. Your “button” is in fact a link that will reach your application endpoint.
  2. You use JavaScript in your frontend to send an AJAX request to your Adonis endpoint.

Thanks for that clarification @romain.lanz. Much appreciated.