小编Val*_*lli的帖子

承诺内部承诺:从子承诺中返回变量的正确方法是什么?(JS)

我有这样的功能:

function top() {

  //promise1
  ParentPromise({
    ...some code here...
  }).then(function() {


    //promise2
        ChildPromise({
          ..some code here...
        }).then(function(response) {
         var result = response.result.items;

        });

});

};
Run Code Online (Sandbox Code Playgroud)

我需要以这种方式返回结果值:

var myresult = start();
Run Code Online (Sandbox Code Playgroud)

我怎么能这样做?谢谢

javascript promise

39
推荐指数
2
解决办法
4万
查看次数

未经身份验证的使用超出了 Google Api 日历的每日限制

我正在测试示例代码。它一直有效,但突然间我得到:

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "dailyLimitExceededUnreg",
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
    "extendedHelp": "https://code.google.com/apis/console"
   }
  ],
  "code": 403,
  "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
 }
}
Run Code Online (Sandbox Code Playgroud)

同样,它一直有效。什么都没有改变。我知道设置控制台开发的东西和 blablabla。我想知道这个问题的原因。

这是我的脚本:

  gapi.client.init({
        'apiKey': 'xxxxxxxx',

        'discoveryDocs': ["https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest"],
        'clientId': 'xxxx.apps.googleusercontent.com',
        'scope': 'https://www.googleapis.com/auth/calendar.readonly https://www.googleapis.com/auth/calendar',
      }).then(function() {


            gapi.client.calendar.events.list({
              'calendarId': 'primary',
              'timeMin': (new Date()).toISOString(),
              'showDeleted': false,
              'singleEvents': true,
              'maxResults': 10,
              'orderBy': 'startTime' //from input
            }).then(function(response) {
             var events = response.result.items; …
Run Code Online (Sandbox Code Playgroud)

javascript google-api google-console-developer

4
推荐指数
1
解决办法
9051
查看次数