Google Api Batchrequest发出错误消息

时间:2014-01-08 11:12:29

标签: javascript jquery google-api

我正在对日历api进行批量请求:

function deleteExisting() {
    var ruEvent = /^\[RU\]/;
    gapi.client.load('calendar', 'v3', function() {
        var request = gapi.client.calendar.events.list({
            'calendarId': calendar,
            'timeMin': firstDate,
            'timeMax': lastDate
        });

        var delBatch = gapi.client.newHttpBatch();

        request.execute(function(resp) {
            for (var i = 0; i < resp.items.length; i++) {
                var item = resp.items[i];
                if (ruEvent.test(item.summary)) {
                    var delRequest = gapi.client.calendar.events.delete({
                        'calendarId': calendar,
                        'eventId': item.id
                    });
                    delBatch.add(delRequest);
                }
            }
            delBatch.execute( function(respBatch, raw) {
                console.log(respBatch);
                console.log(raw);
            });
        });
    });
}

直到delBatch.execute()一切正常。批处理被填满,但是当我执行它时,它会出错:

Uncaught TypeError: Cannot read property 'Content-Type' of undefined    cb=gapi.loaded_0:605:336
  Jm    cb=gapi.loaded_0:605:336
  (anonymous function)  cb=gapi.loaded_0:599:133
  _.af  cb=gapi.loaded_0:28:301
  hG.execute    cb=gapi.loaded_0:599:113
  (anonymous function)  main.js:242:22
  Om    cb=gapi.loaded_0:614:408
  Lm.Yx cb=gapi.loaded_0:612:611
  Mm    cb=gapi.loaded_0:612:510
  (anonymous function)  cb=gapi.loaded_0:145:460
  _.T.E.__cb    cb=gapi.loaded_0:77:262
  g cb=gapi.loaded_0:71:67
  c cb=gapi.loaded_0:62:26

由于它已经缩小了,我不能从头到尾,我做错了什么?

0 个答案:

没有答案