Categories: php, reactjs, laravel

Send data to MySQL database using React Native and Laravel?

1 answer

I have a website application built with Laravel, I want to create a registration form into the React Native mobile app and send that data to the MySQL database to store in their respective columns.

What's the proper way of doing this?

Received answer to this question:
The best answer according to the author of the question:

This is a fairly open-ended question, but I'll provide a few basic pointers.

  • First, you'll want to do client-side validation of registration form data, checking for things like required fields, password length, etc. There are many ways of doing that, here is one: https://medium.com/@pavsidhu/validating-forms-in-react-native-7adc625c49cf

  • Your (validated) form data will make a POST request, with the form data as the POST body, to an API endpoint you will create in Laravel: https://blog.pusher.com/build-rest-api-laravel-api-resources/

  • The endpoint will do any validation that can only be done server-side. This depends on your application, but for instance if you are building a user registration form, you will want to check to see if there is already a user by that email address.

  • After validation, you'll want to save the data to the database with the laravel model you create for this form, if it doesn't already exist. The article above will show you how to do this.