A
A
alexfrolov_xcx2017-10-24 19:01:58
Yii
alexfrolov_xcx, 2017-10-24 19:01:58

How to link frontend react app to backend?

How to connect frontend (in React) and backend (in Yii)? The bottom line: there is a frontend that includes a large form with fields: inputs, chboxes, text fields, etc. ... arrays of data for processing in the form are passed to me as a JSON file... no problem with that... problems with validation - it's implemented using Yii but how do I connect it with the react application if I initially render the entire page in 1 tag? Bagkender can't work with inputs because he doesn't see them from the beginning... please explain on your fingers)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Decadal, 2017-10-24
@Decadal

make an API.
The frontend should call on the methods that the backend will provide and develop.
It will look like this

//front: 
data = {"id":1,"name":"someName"}; //....
apiUrl = "/users/"+data.id; 
sendAjax(apiUrl, data);
//back: 
UsersController {
   function actionUpdate($id) {
      //load POST  
   }
}

To describe the api, it is recommended to use Swagger

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question