Answer the question
In order to leave comments, you need to log in
How are requests made in React for a php file?
In general, there is absolutely no picture in front of your eyes how React implements this. There is a lot of information on the Internet, but
I generally have the dumbest task. Get info from a php file and not from https://......ru '
and how to prepare the right answer for such a request?
I understand that the topic is simple to business, but I really killed two days and did not understand anything at all.
On all sites the same thing ..... But I'm not catching up.
fetch('https://jsonplaceholder.typicode.com/todos/1')
.then(response => response.json())
.then(json => console.log(json))
Answer the question
In order to leave comments, you need to log in
Your php file should give something to some address. To do this, as written above, you need PHP to work in conjunction with the server.
What are you doing in your PHP? Are you submitting data in JSON format?
It seems to me that this is the simplest and most common way to organize an API.
Given that you almost didn’t give any information, I can imagine the following simple scheme:
1) PHP gives JSON,
2) React receives it and works with it further.
Any difficulties in implementing this scheme?
Or do you have a different approach?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question