@PitaJ said in Chat REST API endpoint changes:
It's not a big deal. /api/chats
returns the relative url you need, so doing something like this isn't hard:
fetch('/api/chats')
.then(body => body.text())
.then(url => fetch(url))
.then(body => body.json())
.then(result => {
// do something with your resulting object
});
Yeah, it is not difficult, but it is totally illogic. If you do a API REST, please, do it well or don't do it. It's obvious that /api/chats will show actual logged user chats. It is not necessary to add the username in the endpoint url. An user cannot read other users chats, it is absurd.
Yes you can do two requests to fetch the user chats, you can do all the request you want, why do you not add more? If you are developing a mobile app to use the REST API, it doesn't matter how many request you do, it doesn't matter if your app consume all the data the user has contracted.
Yes, it's not difficult to make two or more request, but it is not efficient, and it isn't a well designed API. To do a bad API, don't do anything and save your time.
Also, if you think that it is well designed, please, do all your API equal. /api/notifications should be /api/user/{userslug}/notifications if we follow the same logic. It is bad designed, but at least follow the same logic.