Backend with mysql database and frontend in javascript(React-Native)

Asked

Viewed 2,696 times

0

I am developing an application in javascript(for android)e I would like to use mysql as database for this application, however I could not use mysql in the same code so I did some searches that indicated to separate by backend and frontend only that I do not know about it. If anyone has any link explaining (it can be in English/Spanish), or explain to me how to do this backend (java preference) and how to include this code in js I would be grateful!

  • You are developing an application that can exchange information with Mysql only for Registration confirmation!!

1 answer

4


Pedro, I believe your case is a little lower. I don’t know what you want to develop, what kind of service you want, but the ideal would be to separate the layers yes, following this concept:

  • React/Javascript to Front-end
  • REST service to deliver data
  • Do not embed data in App/Do not use local database

Local database is good only for quick query services, like, Book, where it has all the chapters written there.

The REST service I suggest, it doesn’t matter much what language you do, Java, PHP. NET, whatever, the important thing is that this layer converse with the Database, Mysql or Postgresql or whatever and deliver the data to your application, regardless of whether it is Android/iOS or even a website, because you serve all your applications independent of the platform.

A simple article to create an API: https://www.leaseweb.com/labs/2015/10/creating-a-simple-rest-api-in-php/

Example of Use:

  • In React you create a registration form
  • Send by AJAX to the URL http://rest.seusite.com/api/v1/users/add
  • The service adds the registration and returns ok, or false, depends on..
  • Your React application responds to successful registration and redirects to the user list screen
  • in turn this user list screen requests another ajax for http://rest.seusite.com/api/v1/users/list
  • Here returns a JSON with all registered users
  • Your React application Lists users of your REST application
  • And so it goes.....

I hope you understand the concept and understand that there is no solution to your case but several. Abs

  • 1

    Thank you, I’ve been doing some research today and it’s all in line with what you answered. I had only found solutions in php and was trying to escape because I have no experience in php and really realized that there are several solutions! Thanks!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.