title: Response undefined - aws-api-gateway-client
body: <p>I have created an AWS API Gateway to invoke a Lambda function to generate random numbers:</p>
  
  <p>Lambda Function :</p>
  
  <pre><code>exports.handler = (event, context, callback) =&gt; {
  let min = parseInt(event.min);
  let max = parseInt(event.max);
  let generatedNumber = Math.floor(Math.random() * max) + min;
  context.done(null, {generatedNumber: generatedNumber});
  };
  </code></pre>
  
  <p>Body mapping Template in API gateway for get method:</p>
  
  <pre><code>{
      "min" : $input.params('min'),
      "max" : $input.params('max')
  }
  </code></pre>
  
  <p>When I access API endpoint like below:
  <a href="https://abcdefgh.execute-api.ap-south-1.amazonaws.com/DEV/number?min=10&amp;max=20" rel="nofollow noreferrer">https://abcdefgh.execute-api.ap-south-1.amazonaws.com/DEV/number?min=10&amp;max=20</a></p>
  
  <p>I get the proper response :</p>
  
  <pre><code>{"generatedNumber":28}
  </code></pre>
  
  <p>But when I try to access the API in node.js using aws-api-gateway-client I am receiving the below response :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>_currentUrl: 'https://abcdefgh.execute-api.ap-south-1.amazonaws.com/DEV/number' },
    response: undefined</code></pre>
  </div>
  </div>
  </p>
  
  <p>The current url should be set to '<a href="https://abcdefgh.execute-api.ap-south-1.amazonaws.com/DEV/number?min=20&amp;max=40" rel="nofollow noreferrer">https://abcdefgh.execute-api.ap-south-1.amazonaws.com/DEV/number?min=20&amp;max=40</a>' but it is set to '<a href="https://abcdefgh.execute-api.ap-south-1.amazonaws.com/DEV/number" rel="nofollow noreferrer">https://abcdefgh.execute-api.ap-south-1.amazonaws.com/DEV/number</a>'. </p>
  
  <p>Here is my node.js code to access this api:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let AWS = require('aws-sdk');
  AWS.config.loadFromPath('./config.json');
  //AWS.config.region = 'ap-south-1';
  let lambda = new AWS.Lambda();
  let apigClientFactory = require('aws-api-gateway-client').default;
  let config = {
      invokeUrl: 'https://abcdefgh.execute-api.ap-south-1.amazonaws.com/DEV',
      accessKey: '&lt;access-key&gt;',
      secretKey: '&lt;secret-key&gt;',
      region: 'ap-south-1'
  };
  let apigClient = apigClientFactory.newClient(config);
  let apiParams = '{"min": 20,"max": 40}';
  let body = {
      
  }
  
  let additionalParams = {
     
  }
  apigClient.invokeApi(apiParams, '/number', 'GET', additionalParams, body)
      .then(function (result) {
          console.log(result);
      })
      .catch(function (error) {
          console.log(error);
      });</code></pre>
  </div>
  </div>
  </p>
  
  <p>I tried changing apiParams to :</p>
  
  <pre><code>let apiParams = {"min": 20,"max": 40};
  </code></pre>
  
  <p>The I receive the below error:
  <code>
  '{"message": "Could not parse request body into json: Unexpected character (\\\',\\\' (code 44)): expected a value\\n at [Source: [B@42feb146; line: 2, column: 14]"}' } }
  </code>
  What is wrong in my code?</p>
  
  <p>Thanks in advance</p>