Can React-Router point directly to a route defined with Express instead of rendering a component?

北城余情 提交于 2020-04-18 05:45:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!