ESP32 mDash "Alexa turn on Pin2" IoT aws lambda call mdashRequest

We are trying to have Alexa turn on and IO pin 2 in an esp32
When we save the mdashRequest function in mdashcall.js and call it with node mdashcall.js it works.

I copy the code from Call device function using Node.js

When it is called within the Lambda function it does not work.
Here are the relatives Snippets calling mdashRequest in file index.js in a lambda function:

THE PROBLEM WAS THE Java Version Node.js8.10 change to Node.js10x in AWS Lambda function

//File index.js called in a AWS Lambda function

const Alexa = require('ask-sdk-core');
var https = require('https');

// mdashRequest definition
var mdashRequest = function(apiToken, deviceID, method, params, func) {
  return new Promise(function(resolve, reject) {
    var received = '';
    var strParams = JSON.stringify(params || {});
    var url = 'https://mdash.net/api/v2/devices/' + deviceID + '/rpc/' +
        method + '?access_token=' + apiToken;
    var options = {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Content-Length': strParams.length
      }
    };
    var req = https.request(url, options, function(res) {
      res.on('data', data => received += data);
      res.on('end', () => resolve(received));
    });
    req.on('error', err => reject(err));
    req.write(strParams);
    req.end();
    });
};

const SetPinOnHandler = {
  canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === 'IntentRequest'
      && handlerInput.requestEnvelope.request.intent.name === 'SetPinOnIntent';
  },
  handle(handlerInput) {

    const slots = handlerInput.requestEnvelope.request.intent.slots;
    const l = slots['Pin'].value;
    const speechText = `Turn On Pin ${l}.`
   
    if(l == "2")
    {
        var ACCESS_TOKEN = 'TOKENTOKENTOKENTOKENTOKEN';
        var DEVICE_ID = 'd6';
        var METHOD = 'setPin';
        var PARAMETERS = {pin: 2, val: 1};

        // example call
        mdashRequest(ACCESS_TOKEN, DEVICE_ID, METHOD, PARAMETERS)
            .then(response => console.log('RESPONSE:', response))
            .catch(err => console.error('ERROR:', err));
    }

    return handlerInput.responseBuilder
      .speak(speechText) 
      .getResponse();
  },
};
```![ChangeToJS10|690x316](upload://zkMt1Nas8Ue8IVp19hvJPm9EEzg.png)