Answer the question
In order to leave comments, you need to log in
Can I make an ajax request to localhost?
Deployed a react project to localhost:8080.
There is a data.json file in the project root.
Can I make an ajax request to it? - if - yes,
how?
Answer the question
In order to leave comments, you need to log in
ajax request will somehow contact your server. But data.json is just data. If you need to pass them through ajax, see how it's done, you can here
If everything is on the same domain (localhost), then why not?
There will be an error in the console if something goes wrong.
In extreme cases, you will have to configure the Access-Control-Allow-Origin header on the server.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question