【问题标题】:Google Tag Manager API example throwing "Uncaught RangeError: Maximum call stack size exceeded" error in consoleGoogle Tag Manager API 示例在控制台中抛出“Uncaught RangeError: Maximum call stack size exceeded”错误
【发布时间】:2017-12-01 16:34:43
【问题描述】:
【问题讨论】:
标签:
javascript
api
google-api
google-tag-manager
【解决方案1】:
这是因为第 47 行的 checkAuth() 函数在递归循环中调用自身。
我通过更改调用函数的名称来修复它-
function checkAuthVal(immediate) {
var authorizeCheckPromise = new Promise((resolve) => {
gapi.auth.authorize(
{ client_id: CLIENT_ID, scope: SCOPES.join(' '), immediate: immediate },
resolve);
});
authorizeCheckPromise
.then(handleAuthResult)
.then(loadTagManagerApi)
.then(runTagManagerExample)
.catch(() => {
console.log('You must authorize any access to the api.');
});
}
/**
* Check if current user has authorization for this application.
*/
function checkAuth() {
checkAuthVal(true);
}
这行得通!