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

233
Visualizações
Google Calendar API CalendarList.list() returns a weird object - JS

I want to get the list of the calendars of a user with JS by using CalendarList.list() as stated in the documentation. But for me I only get a weird object as response, that always looks like this:

{
    "Yd": 1,
    "mb": {
        "Vf": null,
        "yh": {
            "path": "/calendar/v3/users/me/calendarList",
            "method": "GET",
            "params": {},
            "headers": {},
            "root": "https://www.googleapis.com",
            "apiId": "calendar:v3"
        },
        "Cl": "auto",
        "G_": false,
        "VN": false,
        "aQ": false
    }
}

I'm using the standard code from the quickstart which works fine for me, only this one request returns a weird result.

It looks like this in my code (just the part of it that should be interesting):

function initClient() {
      gapi.client.init({
        apiKey: API_KEY,
        clientId: CLIENT_ID,
        discoveryDocs: DISCOVERY_DOCS,
        scope: SCOPES
      }).then(function() {
        // Listen for sign-in state changes.
        gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);

        // Handle the initial sign-in state.
        updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
        authorizeButton.onclick = handleAuthClick;
        signoutButton.onclick = handleSignoutClick;
      }, function(error) {
        changeSpanText(JSON.stringify(error, null, 2));
      });
    }


function updateSigninStatus(isSignedIn) {
      if (isSignedIn) {
        authorizeButton.style.display = 'none';
        signoutButton.style.display = 'flex';
        changeSpanText("🎉 You have been logged in succesfully");
        console.log(gapi.client.calendar.calendarList.list());
      } else {
        authorizeButton.style.display = 'flex';
        signoutButton.style.display = 'none';
        changeSpanText("");
      }
    }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I was able to reproduce the issue using the code shared and effectively, this is something related to how the response is output to the console, making a few modifications like below:

            function updateSigninStatus(isSignedIn) {
            if (isSignedIn) {
                authorizeButton.style.display = 'none';
                signoutButton.style.display = 'flex';
                gapi.client.calendar.calendarList.list({}).then(function (response) { // Handle the results here (response.result has the parsed body).
                    console.log("Response", JSON.stringify(response, null,2));
                }, function (err) {
                    console.error("Execute error", err);
                });

            } else {
                authorizeButton.style.display = 'flex';
                signoutButton.style.display = 'none';
            }
        }

I got a successful and correctly formatted output:

enter image description here

If instead of the entire output you wish to have only some of the detail fields like 'summary' you can do the below:

            function updateSigninStatus(isSignedIn) {
            if (isSignedIn) {
                authorizeButton.style.display = 'none';
                signoutButton.style.display = 'block';
                listCalends();

            } else {
                authorizeButton.style.display = 'block';
                signoutButton.style.display = 'none';
            }
        }
         function listCalends() {
            gapi.client.calendar.calendarList.list().then(function (response) {
               var calendar = response.result.items;
               var strinx = calendar;
               console.log('Calendars owned by this user are: ');
               for (let index = 0 ; index < strinx.length; index++) {                    
                  console.log( strinx[index]['summary']);                      
               } 
            });
        }

Recommendation:

If you are unsure as how to go about doing something with Google APIs using Javascript I encourage you to use their Try this API and click on the 'Javascript' option where it will show you how the request was made so you can have some reference for future projects.

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