When crafting a RESTful API, all the following are valid (since 2014 when the GET standard allowed a body):
(1) GET, users/1
(2) GET, users?id=1
(3) GET, users, where the body is {id:1}
I am using React and netlify-lambda to run local .netlify/functions.
I can access event.queryStringParameters for (2), and event.body for (3), but how do I access the path parameters (1) ? In AWS lambda this is supported as event.pathParameters
Do I need to set up routing somewhere?
I’m don’t really like the idea of using
let id = event.path.split(’/’)[3];