How to connect MySQL database to ReactJS app?

前端 未结 3 1197
暖寄归人
暖寄归人 2020-12-04 00:23

I have build a Todo App with create-react-app. The store I\'m using is based on Local Storage(JS attribute of object window). Now I created a MySQL databases and want to con

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-04 00:34

    You can't connect them directly.

    JavaScript running in a web browser cannot speak the MySQL protocol (nor can it make raw network connections that would be needed to write an implementation in JS).

    Instead, create a web service (in the programming language of your choice, which could be JavaScript running on Node.js (e.g. the code you have already + Express.js + some glue) and use Ajax to communicate with it.

提交回复
热议问题