You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Processing Common Handler Node Js Code in MCS

edited Aug 27, 2017 7:00AM in Digital Assistant & Mobile

Summary

Processing Common Handler Node Js Code in MCS

Content

Hi,

In my custom api nodejs code i am putting the common get and post in a common service handler file.

Something like this

module.exports = {

CommonHandlerPostMethodFunction:

       function (req, res, connector) ;

      var errorMsg;

            var finalResponse;

      var headerIndex = JSON.stringify(

             req.headers).search('application/json');

      var versionNumberIndex = JSON.stringify(

             req.headers).search('x-api-version');

      var reqBody = JSON.stringify(req.body);

      console.info('Req body ' + reqBody);

            res.header('Access-Control-Allow-Origin','*'); 

      if (0 > headerIndex) {

                    finalResponse = jbuilder.encode(function (json) {

                         json.set('Response', function (json) {

                              json.set('responseCode', '415');

                              json.set('responseMessage', 'Unsupported media-type');

                         });

                        

                    });

      res

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!