The lambda I am working on gets triggered through API gateway. I want to extract the a specific value from the path in the URL.
Sample URL : {id}/contacts
or
{id-0}/{id}/contacts
In order to extract the path variable I am using event.pathParamters
which gives me the value, but I need to only extract {id} from the path.
I am using the following code to split the path param and extract the {id}, but this is not a feasible option:
arr = path.split("/");
id = arr[arr.length-2];
Are there better ways to extract {id}? The position of this id will be always last right before api name (in his case <<contacts>>).
