2

I have a scenario where I can take a student Id as input via a part variable and return some data back as JSON objects where JavaScript handles the response as a part of AJAX call.

Suppose the method is called like:

 /student/{studentId}

where studentId is a path variable in Spring MVC web service declaration. Now for requests to /student, the front end gets a "404 Not Found" error.

Where should this be handled on the front end or I should create a new method and map it to the /student call and then throw a custom exception?

asked Dec 23, 2018 at 10:38
1
  • 3
    For a REST endpoint I'd expect /students/<id>(note plural form), and for a GET to /students to provide a list of all students. The method of the front end should probably throw an error without even calling the backend if it isn't given an ID to use. Commented Dec 23, 2018 at 10:49

1 Answer 1

2

Front-End should validate user input based on requirements of the back-end, so if a route need a primary key or any other parameter, front-end should check and ask the user for that parameter and call API, as defined in it, 's the route, always with id, of the curse in back-end this should consider that if no id provided, return a proper error.

answered Dec 23, 2018 at 13:31

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.