javascript - Google API 日历承诺
问题描述
我尝试使用 Google API 日历插入一堆事件并获取插入事件的 ID,但我无法获得响应。我不知道我做错了什么。
这就是我在做什么:
GetEvents //fetchs the user events
.then(insertEvents)
.catch(function (reason) {
console.log(reason);
});
function insertEvents(events) {
var eventsToInsert = [];
if (events.length) {
for (evnt of events) { //Here im creating an array of //"promises" that return the insert method of google API
eventsToInsert.push(insertEvent(evnt.titulo, evnt.lugar, evnt.fechainicio, evnt.fechafin, evnt.tipologia,
evnt.id))
}
console.log('Events ti insert');
console.log(eventsToInsert);
//And here im trying the return the resolved data by the all //promises, but it returns an empty array always
Promise.all(eventsToInsert.map(function (eventToInsert) {
return eventToInsert.execute(function (event) {
console.log('event', event);
return event.id;
});
})).then(function (res) {
console.log(res);
});
}
}
提前致谢
解决方案
推荐阅读
- node.js - NodeJS 请求承诺 ERR_TLS_CERT_ALTNAME_INVALID
- microsoft-graph-api - 带有截止日期标志的 SendMail 返回 ErrorInvalidArgumentError
- reactjs - Polaris React App Bridge 文档中 OAuth 示例的用途是什么?
- java - spring boot @transactional 如果成功则为 true
- sockets - 将按需 TCP 消息触发到可重新连接、不可共享的 Netty 管道的正确方法是什么?
- windows - 如何使用 PowerShell 创建批处理文件
- javascript - 苹果是否允许在应用商店中使用 WkWebView 制作游戏?
- css - 如何使用 css 将电话输入分成不同的盒子(每个盒子一个数字)
- javascript - 如何在JS中破坏数组中的最后一项?
- javascript - 如何将js中的一堆对象映射到另一个对象