#Actions vs Endpoints?

8 messages · Page 1 of 1 (latest)

covert tundra
#

I don't really understand when one would use one over the other? Are there any cons or trade offs?

daring field
covert tundra
#

So then why would someone ever use endpoints?

daring field
#

Building an API

daring field
#

Fwiw I like to use actions for all internal requests that I need for my app, interacting with a DB etc

And endpoints anytime my app needs to handle a request from outside the application, my personal example is a discord bot that queries my API to get "total upvotes" on an item

simple valve
#

I second Matthew's approach. Endpoints are for stuff that you want to be publicly accessible/exposed easily, actions are internal things

covert tundra
#

That makes sense!
So if I'm not making an api that would be used outside of my frontend, since I'm going to be returning HTMX, I could just use actions for everything.

And then if I was ever interested in making an API other clinets could interact with, maybe for JSON, I would use server api endpoints

#

Thank you so much