UnhandledPromiseRejectionWarning: Error: Not Found at Gaxios.<anonymous> when trying to add event to Google Calendar
UnhandledPromiseRejectionWarning: Error: Not Found at Gaxios.<anonymous> when trying to add event to Google Calendar
我正在尝试在 google 日历中创建一个新事件并将环聊会议 link 发送给用户。我正在使用 GSuite 委托凭证,并且在 Node js 中找到关于此的文档并不容易。我发现这个 post 如何列出事件并且工作正常。但是当我用它来创建事件时,我得到了这个错误:
UnhandledPromiseRejectionWarning:错误:未找到
在 Gaxios。 (C:\optt\node_modules\gaxios\build\src\gaxios.js:73:27)
在 Generator.next ()
在履行 (C:\optt\node_modules\gaxios\build\src\gaxios.js:16:58)
在 processTicksAndRejections (internal/process/task_queues.js:97:5)
(节点:23328)UnhandledPromiseRejectionWarning:未处理的承诺拒绝。这个错误要么是在没有 catch 块的情况下在异步函数内部抛出,要么是因为拒绝了一个没有用 .catch() 处理的承诺。要在未处理的承诺拒绝时终止节点进程,请使用 CLI 标志 --unhandled-rejections=strict
(请参阅 https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode)。 (拒绝编号:1)
(节点:23328)[DEP0018] DeprecationWarning:未处理的承诺拒绝已弃用。将来,未处理的承诺拒绝将以 non-zero 退出代码终止 Node.js 进程。
这是我的代码:
const google = require("googleapis").google;
const calendar = google.calendar("v3");
var event = {
'summary': 'Google I/O 2015',
'location': '800 Howard St., San Francisco, CA 94103',
'description': 'A chance to hear more about Google\'s developer products.',
'start': {
'dateTime': '2020-06-12T09:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'end': {
'dateTime': '2020-06-12T12:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'conferenceData': {
'createRequest': {
'conferenceSolutionKey': {
'type': 'hangoutsMeet'
},
'requestId': 'iyfuted65e3ers'
}
},
'attendees': [
{'email': 'hjg@example.com'},
{'email': 'sbrin@example.com'},
],
'reminders': {
'useDefault': false,
'overrides': [
{'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 10},
],
},
};
(async function () {
const scopes = ['https://www.googleapis.com/auth/calendar'];
const keyFile = './credentials.json';
const client = await google.auth.getClient({
keyFile,
scopes,
});
// Delegated Credential
client.subject = 'example@test.com';
const res = await calendar.calendarList.insert({
auth: client,
calendarId: 'primary',
conferenceDataVersion: 1,
resource: event,
});
//listEvents();
console.log(JSON.stringify(res.data));
})();
我插入的数据有误。如果有人需要,这里是编写代码:
const google = require("googleapis").google;
const calendar = google.calendar("v3");
var event = {
'summary': 'Google I/O 2015',
'location': '800 Howard St., San Francisco, CA 94103',
'description': 'A chance to hear more about Google\'s developer products.',
'start': {
'dateTime': '2020-06-12T09:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'end': {
'dateTime': '2020-06-12T12:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'conferenceData': {
'createRequest': {
'conferenceSolutionKey': {
'type': 'hangoutsMeet'
},
'requestId': 'iyfuted65e3ers'
}
},
'attendees': [
{'email': 'hjg@example.com'},
{'email': 'sbrin@example.com'},
],
'reminders': {
'useDefault': false,
'overrides': [
{'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 10},
],
},
};
(async function () {
const scopes = ['https://www.googleapis.com/auth/calendar'];
const keyFile = './credentials.json';
const client = await google.auth.getClient({
keyFile,
scopes,
});
// Delegated Credential
client.subject = 'example@test.com';
const res = await calendar.calendar.events.insert({
auth: client,
calendarId: 'primary',
conferenceDataVersion: 1,
resource: event,
});
//CreateEvents();
console.log(JSON.stringify(res.data.hangoutLink));
})();
我正在尝试在 google 日历中创建一个新事件并将环聊会议 link 发送给用户。我正在使用 GSuite 委托凭证,并且在 Node js 中找到关于此的文档并不容易。我发现这个 post 如何列出事件并且工作正常。但是当我用它来创建事件时,我得到了这个错误:
UnhandledPromiseRejectionWarning:错误:未找到
在 Gaxios。 (C:\optt\node_modules\gaxios\build\src\gaxios.js:73:27)
在 Generator.next ()
在履行 (C:\optt\node_modules\gaxios\build\src\gaxios.js:16:58)
在 processTicksAndRejections (internal/process/task_queues.js:97:5)
(节点:23328)UnhandledPromiseRejectionWarning:未处理的承诺拒绝。这个错误要么是在没有 catch 块的情况下在异步函数内部抛出,要么是因为拒绝了一个没有用 .catch() 处理的承诺。要在未处理的承诺拒绝时终止节点进程,请使用 CLI 标志 --unhandled-rejections=strict
(请参阅 https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode)。 (拒绝编号:1)
(节点:23328)[DEP0018] DeprecationWarning:未处理的承诺拒绝已弃用。将来,未处理的承诺拒绝将以 non-zero 退出代码终止 Node.js 进程。
这是我的代码:
const google = require("googleapis").google;
const calendar = google.calendar("v3");
var event = {
'summary': 'Google I/O 2015',
'location': '800 Howard St., San Francisco, CA 94103',
'description': 'A chance to hear more about Google\'s developer products.',
'start': {
'dateTime': '2020-06-12T09:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'end': {
'dateTime': '2020-06-12T12:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'conferenceData': {
'createRequest': {
'conferenceSolutionKey': {
'type': 'hangoutsMeet'
},
'requestId': 'iyfuted65e3ers'
}
},
'attendees': [
{'email': 'hjg@example.com'},
{'email': 'sbrin@example.com'},
],
'reminders': {
'useDefault': false,
'overrides': [
{'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 10},
],
},
};
(async function () {
const scopes = ['https://www.googleapis.com/auth/calendar'];
const keyFile = './credentials.json';
const client = await google.auth.getClient({
keyFile,
scopes,
});
// Delegated Credential
client.subject = 'example@test.com';
const res = await calendar.calendarList.insert({
auth: client,
calendarId: 'primary',
conferenceDataVersion: 1,
resource: event,
});
//listEvents();
console.log(JSON.stringify(res.data));
})();
我插入的数据有误。如果有人需要,这里是编写代码:
const google = require("googleapis").google;
const calendar = google.calendar("v3");
var event = {
'summary': 'Google I/O 2015',
'location': '800 Howard St., San Francisco, CA 94103',
'description': 'A chance to hear more about Google\'s developer products.',
'start': {
'dateTime': '2020-06-12T09:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'end': {
'dateTime': '2020-06-12T12:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'conferenceData': {
'createRequest': {
'conferenceSolutionKey': {
'type': 'hangoutsMeet'
},
'requestId': 'iyfuted65e3ers'
}
},
'attendees': [
{'email': 'hjg@example.com'},
{'email': 'sbrin@example.com'},
],
'reminders': {
'useDefault': false,
'overrides': [
{'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 10},
],
},
};
(async function () {
const scopes = ['https://www.googleapis.com/auth/calendar'];
const keyFile = './credentials.json';
const client = await google.auth.getClient({
keyFile,
scopes,
});
// Delegated Credential
client.subject = 'example@test.com';
const res = await calendar.calendar.events.insert({
auth: client,
calendarId: 'primary',
conferenceDataVersion: 1,
resource: event,
});
//CreateEvents();
console.log(JSON.stringify(res.data.hangoutLink));
})();