reactjsexpressrequestendpointdynamic-routing

ExpressJs dynamic routing not working properly with react get request


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.


Solution

  • 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 as http://localhost:3000/products/${name}. Then the problem solved. I can send request to dynamic endpoint like '.../${name}' not '.../:name'.