Reputation: 344
I working with next for creating a basic API tha read a local file json.
I would like to make a dynamic api base on what call recive
My api folder is
api
--book
---[id].js
----content
-----[id].js
So I could make a get request to https.../book/1 and also to https.../book/1/content/4
I'am right? Is possible do it?
I've try but with no good result
Thanks
Upvotes: 0
Views: 666
Reputation:
Yes I think you could do it like this:
api
book // folder
[bookId] // folder
index.js // /api/book/1 endpoint
content // folder
[contentId].js // /api/book/1/content/4 endpoint
Edit: add image of folder structure
Upvotes: 1