I don't know why UID returns null. userSessionCheck () contains code to keep the session after login. user.uid gives the same result And Below is my code and error code
--
Uncaught TypeError: Cannot read property 'uid' of null
$(document).ready(function(){
auth = firebase.auth();
db = firebase.database();
storage = firebase.storage();
userInfo = auth.currentUser;
userSessionCheck();
update_profile();
function update_profile() {
var mypage_Ref = db.ref('users/' + userInfo.uid).once('value').then(function(snapshot){
console.log(snapshot.val());
profileImageUrl = $('#update_email').val(snapshot.val().profileImageUrl);
email = $('#update_email').val(snapshot.val().email);
u_name = $('#update_name').val(snapshot.val().username);
job = $('#update_job').val(snapshot.val().job);
var html =
'<div class="profile">' +
'<img src="'+profileImageUrl+'" id="profile_img">'+
'<div class="form_g">'+
'<label>email</label>'+
'<input type="text" style="text-align: center" id="update_email" placeholder="'+ email +'">'+
'</div>'+
'<div class="form_g">'+
'<label>name</label>'+
'<input type="text" style="text-align: center" id="update_name" placeholder="'+u_name+'">'+
'</div>'+
'<div class="form_g">'+
'<label>job</label>'+
'<h5 id="update_job">'+job+'</h5>'+
'</div>'+
'<button type="button" class="s-btn" id="info_submit" style="width: 100%; margin-top: 30px;">update</button>'+
'</div>';
$('#profile_form').append(html);
});
}
});
Aucun commentaire:
Enregistrer un commentaire