Google API календарь Обещания - PullRequest
0 голосов
/ 07 мая 2018

Я пытаюсь вставить группу событий с помощью Календаря API Google и получить идентификаторы вставленных событий, но не могу получить ответ. Я не знаю, что я делаю не так.

Вот что я делаю:

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);
        });

    } 

}

Заранее спасибо

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...