我有这样的功能:
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)
我怎么能这样做?谢谢
我正在测试示例代码。它一直有效,但突然间我得到:
{
"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)