0

Javascript community generally follows camel case naming convention, whereas while writing REST api URLs follow snake case naming conventions.

What would be the better naming convention for the payloads which will be sent in HTTP requests/responses?

If the answer is snake_case then will it be better to convert each and every key in the payload to be converted to snake case while going out of the Node JS server and be converted to camelCase while coming into the Node JS server and should same be followed on the client side if it is also using JS environment?

marked as duplicate by gnat, Bart van Ingen Schenau, Robert Harvey, jwenting, Arseni Mourzenko Jun 21 '18 at 8:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

The underlying transport method of an API should be hidden by a Client class.

A JavaScript Client will of course expose methods which follow the javascript naming conventions.

eg.

function niceCamelCaseFunctionName()
{
    fetch('./api/snake_case_resource')
      .then(
        function(response) {
          response.json().then(function(data) {
            var r = {
               niceProperty : data.EvilPascalCase
            } 
            return r
          });
        }
      )
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.