I have a simple api and client application. Api written with express js and client-side is react.
I arranged the react dynamic routing but when I try to send get request to endpoint with dynamic path, I cannot get the dynamic path and dynamic path parameter. It is like no request coming from client to api. What is the reason of this ?
Note: I can get data from api and I can post data to api. The problem occurs only with dynamic routing. Thanks for your help.
2
Answers
I was sending request to
http://localhost:3000/products/:name
but that makes no sense because there is no such endpoint. I changed request path ashttp://localhost:3000/products/${name}
. Then the problem solved. I can send request to dynamic endpoint like '.../${name}' not '.../:name'.Make sure you use :slug for the router
example: /auth/v1/products/:name