How WebsiteController differs from AcronymsController

I noticed that in AcronymsController we have a route like /api/acronyms, but then in WebsiteController, the paradigm is different. There’s no api in any of the URLs. Is that because we start with the /index page and everything is based off of that base route? So then we would hit /acronyms instead and show the View for that page? In other words, by using WebsiteController, there are two different ways of getting to the data, one being just API driven, the other being through rendering a page.

Lastly, if we were doing a Single Page App, it seems like then we would have our pages then make requests to the /api/acronyms instead right?

@0xtim Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi @crystaltwix sorry it’s taken me so long to reply!

The reason for having /api in the routes for the controllers are to help differentiate the routes for returning JSON and returning HTML. If you didn’t have any of the Lea stuff you could remove /api if you wanted. And like you said, for the website, everything starts at the route path / so it makes sense to branch off from there.

If you are doing a single page app using React or similar, then yep everything just calls the API. They don’t even have to be the same app!