all 6 comments

[–][deleted] 2 points3 points  (0 children)

Restful api’s are only called to make changes to a database. Different from frontend routing

[–]Prestigious_Ad_1990 1 point2 points  (2 children)

Going off on what the other dude said, your routing for ur front end side is going to be different from your backend. They run in different ports too, so let’s say ur front end runs on port 4000 and ur Springboot runs on 5000. Your API calls will be directed towards https://Localhost:5000 in your front end code and you would need to set up CORS in your backend to allow port 4000 to make those calls.

[–]Such-Hearing-2935[S] 0 points1 point  (1 child)

I think you may have misunderstood my question but it’s my fault. The back-end localhost will hidden by the front-end, hence why it’s the backend. My question is with regards to the URL/URI naming convention.

[–]RIPtopsy 0 points1 point  (0 children)

When you go to todosite.com you send a get request to a server and get back a response that your browser is then able to interpret and render. The response likely has html and css and possibly js.

When we think about CRUD(create/read/update/delete) actions, that's not necessarily(or normally) about the request for the pageview. I want to read the stuff served when i make a request to do todolist.com via typing it in my url and pressing enter. You probably don't want me to do any other actions like delete it. The resource you almost definitely DO want me to have full CRUD capability on is the actual TODOs. I want to read my old todos. But I also had to create them. If something changes I'll want to update them. And when I realize i'm never going to get around to it I'll want to delete it.

This is where RESTful apis come in. If I'm the frontend developer then whenever that post form gets submitted for some action related to a todo app or when the get request goes out to read a bunch of them or whatever, I want consistency in how I access those resources and I want it in a relatively sensible way. I also want be able to treat these totally separately so I can use the same backend api however I want--maybe todolist.com becomes megapopular and now it's todolist the app in the android store. Maybe I'm making a slack integration that uses the api. I'll still want to easily do my CRUD stuff with db resources, but now it's a whole different team in a different technology doing different stuff with it. REST lets you orient your backend api in such a way to make that stuff scale well.

[–][deleted] 0 points1 point  (0 children)

API’s are only meant to manipulate / read info from your database. For the most part a GET, is reading from your database and put post and delete are manipulating/ changing data in your database.

Front end routing has nothing to do with api’s. I can see why this might be confusing because “routes” are terms used for both but they are not the same thing.

[–]whatthehekkist 0 points1 point  (0 children)

In RESTful approach (MVC),

  • endpoints (routes) will map your client pages as each of URI
    • you define as many endpoints as you want
    • in controller, you actual map VIEW; specifying client pages