问题
How I can use React-Router to point directly to a route defined with Express on the backend instead of rendering a component? I want to return valid JSON with no HTML included in the response.
回答1:
React-Router only handles routing on the React frontend.
There is no way for React-Router to point to an Express Route on the back end.
A React component would have to use that API endpoint.
Why not just hit the endpoint manually.
来源:https://stackoverflow.com/questions/61162675/can-react-router-point-directly-to-a-route-defined-with-express-instead-of-rende