chore: added graceful check while accessing path params

This commit is contained in:
Anoop M D 2024-07-10 11:55:12 +05:30
parent b2038c7cc2
commit 1239baf687

View File

@ -82,7 +82,7 @@ const interpolateVars = (request, envVars = {}, collectionVariables = {}, proces
request.data = _interpolate(request.data); request.data = _interpolate(request.data);
} }
each(request.pathParams, (param) => { each(request?.pathParams, (param) => {
param.value = _interpolate(param.value); param.value = _interpolate(param.value);
}); });
@ -107,7 +107,7 @@ const interpolateVars = (request, envVars = {}, collectionVariables = {}, proces
return '/' + path; return '/' + path;
} else { } else {
const name = path.slice(1); const name = path.slice(1);
const existingPathParam = request.pathParams.find((param) => param.type === 'path' && param.name === name); const existingPathParam = request?.pathParams?.find((param) => param.type === 'path' && param.name === name);
return existingPathParam ? '/' + existingPathParam.value : ''; return existingPathParam ? '/' + existingPathParam.value : '';
} }
}) })