How can I move the variable userID out of its' scope (once it returned from the ajax POST call), because I would need its' value below (in the GET request)? Should I use a callback?
firebaseAUTH.signInWithEmailAndPassword(email, password).then(function (user) {
console.log('user has signed in with e-mail address: '+user.email+' and user ID: '+user.uid)
firebaseAUTH.currentUser.getToken(true).then(function(idToken) {
// Send token to your backend via HTTPS (JWT)
$.ajax(
{
url: '/auth',
type: 'POST',
data: {token: idToken},
success: function (response){
var userID = response.userID
//set database ref, pull out info based on ID
}})
$.get(
{
url: '/members-area/',
data: {userID: userID}
})