我正在运行 Nuxt,并且具有以下功能。我想检查是否经过身份验证,如果没有,则重定向到登录页面。我收到错误window is undefinedThis make 因为这是我的理解asyncdata()是评估服务器端。什么是正确的重定向方式。我尝试使用重定向方法,context但它只会显示我的 404。谢谢
async asyncData(context) {
if (!context.authenticated) {
window.location = `${config.url}/sign_in`;
}
}
Run Code Online (Sandbox Code Playgroud) 根据我找到的所有教程(下面的链接中的一个示例),以下代码段应该允许我连接和查询Google BigQuery.但无论发送或不发送凭据jsons的任何组合,总是会导致相同的错误"BigQuery不是构造函数"我目前正在通过谷歌在线云外壳测试.任何想法都会有所帮助.谢谢 https://cloud.google.com/nodejs/docs/reference/bigquery/1.3.x/BigQuery#createJob
const BigQuery = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const query = 'SELECT * FROM `random.table` LIMIT 100';
bigquery.createQueryJob(query).then(function(data) {
var job = data[0];
var apiResponse = data[1];
console.log(job.getQueryResults())
return job.getQueryResults();
});
Run Code Online (Sandbox Code Playgroud)
错误
/home/v/testServer.js:2
const bigquery = new BigQuery();
^
TypeError: BigQuery is not a constructor
at Object.<anonymous> (/home/user_name/testServer.js:2:18)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
Run Code Online (Sandbox Code Playgroud) 如果我在 BigQuery 中有以下内容example_table。当我使用“原始查询”查询表时,我得到“实际结果”(从那时起)。有没有办法直接查询 BigQuery 以获得“所需结果”
SELECT ID, SUBID FROM `example_table ORDER BY ID
Run Code Online (Sandbox Code Playgroud)
ID | SUBID
12 abc
12 def
12 ghi
34 jkl
34 mno
56 prg
Run Code Online (Sandbox Code Playgroud)
[{
"ID": "12",
"SUBID": "abc"
}, {
"ID": "12",
"SUBID": "def"
}, {
"ID": "12",
"SUBID": "ghi"
}, {
"ID": "34",
"SUBID": "jkl"
}, {
"ID": "34",
"SUBID": "mno"
}, {
"ID": "56",
"SUBID": "prg"
}]
Run Code Online (Sandbox Code Playgroud)
[{
"ID": "12",
"SUBID": ["abc", "def", "ghi"]
}, {
"ID": …Run Code Online (Sandbox Code Playgroud)