I have a REST API written using ASP.NET Core Web API. There are a few business logic based messages I want to send to the clients from the API.
I am in a dilemma on which of the following ways I can use to show the messages:
Assign a unique code(number) for each message, send that code to the clients and decide the message to be shown on the client based on the code received.
Directly send a response to the clients, along with the appropriate developer and user messages for the scenario and display the user message.
I am hesitant on using method 1 as I have multiple clients for the API and the codes should be handled at both the places and would result in duplication of messages but I have read on a stackoverflow thread that method 2 is better as it would help with stuff like localization of messages and is kind of a best practice.
Can you please advise me on which method would be the best or if there is a better way than the two mentioned above?