gmail.js icon indicating copy to clipboard operation
gmail.js copied to clipboard

gmail.get.email_data failing for some reason

Open Brantron opened this issue 7 years ago • 11 comments

I believe I found a bug but want to make sure my code is correct.

gmail.observe.on('view_thread', () => {
  const emailData = gmail.get.email_data()
  console.log(`${emailData}`)
})

Based on the documentation I believe that when I click an email thread, emailData should return an object which contains data about the email.

When I click an email thread the code executes at the proper time. Unfortunately I get the following in the console. The GET seems to be receiving an undefined param which results in an erroneous response format. The behavior is the same even if I move lines 2-3 out of the observer.

screen shot 2018-03-05 at 10 44 14 am

Brantron avatar Mar 05 '18 15:03 Brantron

Hey Brantron.

Thanks for the report. Thanks for the code-sample and the stack-trace. That's good info :)

  • Does this always fail? (Because I can't reproduce with the code provided)
  • Is this a new project or is this something which used to work?
  • Are you using latest Gmailjs?
  • Have you recently upgraded to latest version? (And if so what did you use?)
  • Etc

Basically anything to make it easier to narrow down the problem. Could you also outline what exactly you're trying to achieve?

Maybe there are other ways which doesn't have the same problems. For instance, if you subscribe to the view_email sub-observer, you will receive a api.dom.Email-instance with the event, which might contain the information you need.

If that doesn't do it... Could you provide a little more data/examples to outline this but:

The GET seems to be receiving an undefined param which results in an erroneous response format.

Full query URL for once would be a good start. Second ... What format is the response? JSON? HTML? Can you provide a screenshot from the network-tab in your developer console?

josteink avatar Mar 06 '18 06:03 josteink

I had the same error. Just Update your gmail.js file.

o-x-y-g-e-n avatar Mar 14 '18 04:03 o-x-y-g-e-n

Hi, I am also facing same issue in my project. I am using updated gmail.js file and trying to get "email_ids()". For this I have used below code

var gmailSave = new Gmail($); var email_ids = gmailSave.get.email_ids();

After running above code I got this error console_error

I have debugged it in gmail.js file, Then I found some issue with URL in "api.helper.get.email_data_pre" function. URL - url

After hitting this URL manually I am getting temporary error message. Temporary Error - temporary_error

I have also captured network activities. Headers - network_headers

Response - network_response

Please help.

muraridubey avatar Aug 31 '18 05:08 muraridubey

If you just build the boilerplate project and install that in your browser, this leaves you a working gmail-instance available in the web developer console.

Can you reproduce the error by loading that extension and manually entering the code you've demonstrated here?

If not, it's probably related to how you load your code and when you execute it.

josteink avatar Aug 31 '18 06:08 josteink

Hey!

I hope i can help. Just go to : https://github.com/o-x-y-g-e-n/gmail-extension/blob/master/dist/extension.js

Scroll to the bottom most. Locate a comment 'shivam gohel'.

Yes, i had to manually write that code to make it work. I hope it helps.

o-x-y-g-e-n avatar Aug 31 '18 06:08 o-x-y-g-e-n

The code in your dist-folder does not match the code in the src folder, which is always suspicious. Try cleaning up your code. Ideally the dist-folder shouldn't be committed at all.

From the error-message you're getting, it seems like you're not providing any ID. Maybe you should add some logging to verify the incoming ID in the "open_email" observer?

Also, your code (in dist) has at least issue: Trying to obtain email-ID from DOM while DOM is being rendered, instead of just using the ID variable you already have. Are there any particular reason you do this?

At best it will make your code slower and more error-prone. At worst it will provide you with inconsistent results.

Yes, i had to manually write that code to make it work. I hope it helps.

That probably means it's related to how you load your code.

Try not registered the observer inside the load-observer when everything should be ready.

josteink avatar Aug 31 '18 06:08 josteink

Getting the same issue here. I also tried it with the boilerplate project. Following were the commands that I tried in the console:

var emailID = gmail.get.compose_ids()[0];
var emailData = gmail.get.email_data(emailID);

KonceptGeek avatar Jan 31 '19 21:01 KonceptGeek

As discussed to great lengths in a previous issue, google has effectively obsoleted all XHR-based APIs we’ve used in the past. This particularly includes anything related to gmail.get.email_data().

Now it’s 2019 and it should be considered fundamentally broken.

Consider replacing all use of gmail.get.email_data() with gmail.new.get.email_data().

Please note data-format differs, it has some limitations and it’s not a simple drop-in replacement.

josteink avatar Jan 31 '19 21:01 josteink

Also: compose-ids are not interchangeable with email-ids. They differ significantly.

josteink avatar Jan 31 '19 21:01 josteink

Also: compose-ids are not interchangeable with email-ids. They differ significantly.

What's the best way to extract the metadata and the content of the email being composed?

KonceptGeek avatar Jan 31 '19 21:01 KonceptGeek

gmail.get.composes().

That returns an array of rich objects. Check the documentation.

josteink avatar Jan 31 '19 21:01 josteink

Is it still broken tho? Like it works today pretty well @josteink

MadcowD avatar Jun 07 '23 22:06 MadcowD

Maybe it works. If it does, good for you I guess? :smile:

If it stops working, we have some new APIs which hopefully are not broken.

josteink avatar Jun 09 '23 11:06 josteink

Old issue is old. Closing.

josteink avatar Oct 11 '23 08:10 josteink