KartikTalwar / gmail.js

Gmail JavaScript API
MIT License
3.74k stars 456 forks source link

Reloading window makes the the user email undefined #770

Closed RejownAhmed closed 8 months ago

RejownAhmed commented 8 months ago

Hi, I am using this in one of my extensions. On first page load we get the user mail by:

gmail.get.user_email() // Returns: rejownahmedzisan@gmail.com

However, reloading the window returns: undefined.

Additionally, if I hard reload it's the same but clearing the cache and reloading again returns the email address perfectly.

Here's a screenshot of the pb:-

ss

kamroot commented 8 months ago

I had similar problems. Your extension is loading too early in the DOM lifecycle. If you check the hello world example and follow how they load the extension then it would work.

RejownAhmed commented 8 months ago

Thanks for your reply. Let me check it!

Update: It's working now. For those who are facing the same issue check this repo to know how to initialize the gmail js properly: https://github.com/sripathikrishnan/gmail-sanity-checker