api-gateway-mapping-template
api-gateway-mapping-template copied to clipboard
Error: Cannot read property 'split' of undefined
With nested functions/definitions, an error occurs when the inner value is not defined on the parameters/payload.
Minimal example that causes this problem:
var mappingTemplate = require('api-gateway-mapping-template');
var template = '$util.escapeJavaScript($input.params(\'test\'))';
var params = {
header: {},
querystring: {},
path: {}
};
var payload = '';
var result = mappingTemplate({
template: template,
params: params
payload: payload
});
// Results in error similar to
// Error: Cannot read property 'split' of undefined on $util.escapeJavaScript($input.params('test')) at L/N 1:0
Expected behavior (and as far as I understand, what API Gateway would actually do) is to resolve this to be completely undefined, meaning calls to util functions with an undefined parameter results in an undefined value.