I am new to working with data bases. I have a react app that I would like to connect to a MySQL database. The server is not mine but given by a web provider (strato), using PHP.
Is it generally possible to GET and PUT data via react (meaning javascript) to this data base in a way that I normally work with ajax and a restful API?
I really hope this question provides enough information for an answer :)
Here's a code example from https://github.com/numtel/reactive-mysql-example, file index.js. Have a look at that file and settings.js to see how to set up the connection.
var results = liveDb.select('select * from players order by score desc', [ {
table: 'players'
} ]).on('update', function(diff, data){
var msg = JSON.stringify({
type: 'diff',
data: diff
});
// Send change to all clients
connected.forEach(function(conn){
conn.write(msg);
});
});