D
D
Dima2018-02-23 11:55:48
MySQL
Dima, 2018-02-23 11:55:48

How to take data from mysql database (back to php) and get it in react?

I used to use php for this, but now I need it in react. It seems that I heard that it is necessary to translate the database into JSON on the fly and take it there.
Can I have an explanation for the dumbest teapot?))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Aleksandrovich, 2018-02-23
Dolgoter @DDolgy

Typically, communication between the PHP backend and the React frontend happens through an exchange of data via an API. From React, a request is made to the server with the Api you need, for example, using Featch or Axios, and PHP performs the necessary database manipulations. Naturally, you can send the data you need from React to PHP when requesting.

I
Ilya Bobkov, 2018-02-23
@heksen

import axios from 'axios';

axios.get('/getUserData', {
    params: {
      ID: 12345
    }
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question