简体   繁体   中英

how to make http request at same origin from where front-end is serve to access a directory's file's JSON data in react.js

front-end is served from http://localhost:3000/

I want to access the JSON data which is inside a directory's file

by sending HTTP requests at same-origin http://localhost:3000/

in React.js

is it possible to do that, if it is so, how?

Yes, you have 2 solutions:

  1. import the JSON file
  2. fetch the JSON file from the project (like an external API) see this question for more details about the implementations

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM