Well...
For mysql you can use axios plugin. Is the best way to work with mysql database.
Firebase use asynchronous request, if you want work with both the best way is using axios.
First, you get user from your mysql table, correct?
So.. you do something like that :
return axios.get(server_address¶m=PARAM_VALUE)
.then(response => {
return(response);
}).catch(function(error) {
alert.error(error.message);
});
Axios aways return a JSON response.
You can use GET or POST method.
So... with the JSON, you can send for firebase your data for load or create user.
like that:
return firebase
.auth()
.signInWithEmailAndPassword(loginEmail,loginPassword)
.then( user => {
return user;
})
.catch(error => {
if ((error.code == 'auth/user-not-found') || (error.code == 'auth/invalid-email')) {
return new Promise((resolve, reject) => {
Alert.alert(
'User not found',
'Create ?',
[{
text: 'No',
onPress:() => resolve(),
style:'cancel'
},{
text:'Yes',
onPress: () =>{
firebase
.auth()
.createUserWithEmailAndPassword(loginEmail,loginPassword)
.then(resolve)
.catch(reject)
}
}],
{cancelable: false}
)
})
}
return Promise.reject(error)
})
For a complete guide to axios :
https://github.com/qiangmao/axios#readme
For a complete guide to firebase:
https://firebase.google.com/docs/auth/?hl=en