After reading :
https://restfulapi.net/resource-naming/
I have a question regrading referencing documents in collections when a document has multiple unique IDs.
In the linked material an example is given:
We can identify a single “customer” resource using the URI “/customers/{customerId}”.
or
http://api.example.com/device-management/managed-devices/{device-id} http://api.example.com/user-management/users/{id} http://api.example.com/user-management/users/admin And my example:
http://myserver/api/courses/{id} Which has a js Express function counterpart:
app.get('/api/courses/:id', (req, res) =>... My question is how do I maintain a consistent API if my document (courses) has two unique ID keys that I would like to use.
Such as ID1 & ID2.
How would I code that in express and how would I write the url?
So if I need the two APIs to be:
http://myserver/api/courses/{id1} http://myserver/api/courses/{id2} If I provide two Express routines:
app.get('/api/courses/:id1', (req, res) =>... app.get('/api/courses/:id2', (req, res) =>... And ID1 and ID2 are both the same type (eg. numbers). How does the REST API distinguish these two?
/api/courses/1234and/api/courses/5678could reference the same course but still use the same API