PerBonomi
3 years agoBoss
Endpoint or Javascript?
Hi folks. Wondering if you'd like to give your opinion on this matter. In scenarios where it's possible, do you prefer using an endpoint or inline Javascript? And why?
Benefits of an endpoint:
Drawbacks of an endpoint:
Note I included "publicly accessible" in both the pros/cons. This was intentional. It can be valuable to be able to use this endpoint from outside the community, but that also means you have to take that into consideration when building your endpoint and you may want to include checks for if the user is registered, and check if they have the expected roles.
So, in the end it depends what you're trying to accomplish. For simple data fetches of public APIs, a straight JS ajax call is usually fine. But if you intend to add other logic or want custom output or intend to make community API calls, usually an Endpoint is the better option.