Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

158
Visualizações
CALENDAR API : Event list is different each time i execute it

I have a problem, each time I execute my code to retrieve calendar list, then my events.

calendar list is always the same, however the Events number is different each time I execute the code.

there is a start date and end date, here is my code.

        // Make sure the client is loaded and sign-in is complete before calling this method.
  function execute() {
    return gapi.client.calendar.calendarList.list({})
        .then(function(response) {
                // Handle the results here (response.result has the parsed body).
                 let data = JSON.parse(response.body);

                for (let i = 0; i < data.items.length; i++) {
                         let calendar_id = data.items[i].id;
                         getEvents(calendar_id, function() {
                                 if(i == data.items.length -1) {
                                         addInvoices(Invoices);
                                         console.log(Invoices);
                                 }
                         });
                       
                 };
              },
              function(err) { console.error("Execute error", err); });
  }

       
  function getEvents(calendar_id, callback) {
          let start_date = new Date($('#start_date').val());
          let end_date = new Date($('#end_date').val());
          console.log(start_date);
          console.log(end_date);
    return gapi.client.calendar.events.list({
                 'calendarId': calendar_id,
                 'timeMax': end_date.toISOString(),
                 'timeMin': start_date.toISOString(),
                 'showDeleted': false,
             'singleEvents': true,
                 'orderBy': 'startTime'
         })
                .then(function(response) {
            // Handle the results here (response.result has the parsed body).
            let events = response.result.items;
                        for(let m = 0; m < events.length; m++) {
                                if(!Invoices.includes(events[m]) )
                                        Invoices.push(events[m]);
                        }
                   callback();
            return events;
           },
                          function(err) { console.error("Execute error", err);});
  }

  gapi.load("client:auth2", function() {
    gapi.auth2.init({client_id: "{{ $currentCompany->getSetting('client_id') ? $currentCompany->getSetting('client_id') : '' }}"});
  });  ``` 

Do you have any idea why i got this issue ?
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Fixed, error was in my ajaxcontroller.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda