Register today for Oracle CloudWorld. October 17th - 20th, Las Vegas

Register now

Hillel Cooperman, Senior VP of User Experience Design, has a message for you on Oracle CloudWorld

Watch now
Processing Common Handler Node Js Code in MCS — Cloud Customer Connect
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

Question
7
Views
0
Comments
edited Aug 27, 2017 7:00AM in Digital Assistant and 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');

Howdy, Stranger!

Log In

To view full details, sign in.

Register

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