【发布时间】:2019-04-23 07:28:00
【问题描述】:
我正在使用 GMail API 来检索邮件。消息是机器生成的,因此请遵循类似的格式。
虽然大多数消息都很好,但我得到了一个 DOMException,使用 atob 来解码消息子集的消息体。
我认为我已将其范围缩小到其中包含如下部分的消息:
--------------------- Sudo (secure-log) Begin ------------------------
jeremy => root
--------------
/usr/bin/docker - 5 Time(s).
---------------------- Sudo (secure-log) End -------------------------
具体来说,我认为问题的发生是因为=>。
错误是:
Error parsing DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.
代码片段:
gapi.client.gmail.users.threads.get({
userId: 'me',
id: thread.id
})
.then(function(response){
var
content,
message = response.result.messages[0],
rawContent = message.payload.body.data;
try{
content = atob(rawContent);
}
【问题讨论】:
标签: gmail-api