skip to Main Content

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


  1. Chosen as BEST ANSWER

    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'.


  2. Make sure you use :slug for the router
    example: /auth/v1/products/:name

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search