[英]Connect bigquery view in javascript
I'm pretty new to google Bigquery and Javascript.我对谷歌 Bigquery 和 Javascript 还是很陌生。 I'm trying to add results from a view in Bigquery to an html page.我正在尝试将 Bigquery 中的视图的结果添加到 html 页面。 I'm having a hard time finding examples and tutorials for this.我很难为此找到示例和教程。
My view in bq:我对 bq 的看法:
Field name Type
NrTracked INTEGER
Total INTEGER
Here's what I've started in javascript.这是我在 javascript 中开始的。 Could someone give me tips on how to pull a bigquery view in javascript?有人可以给我关于如何在 javascript 中提取大查询视图的提示吗? Also, not sure I even need the fetch statement??另外,不确定我什至需要 fetch 语句?
<html>
<head>
<script src="https://apis.google.com/js/client.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript"> function getView() {
// UPDATE TO USE YOUR PROJECT ID AND CLIENT ID
var project_id = 'XXXXXXXX';
var client_id = 'XXXXXXXX.apps.googleusercontent.com';
var config = {
'client_id': client_id,
'scope': 'https://www.googleapis.com/auth/bigquery'
};
fetch('https://bigquery.googleapis.com/bigquery/v2/projects/{XXXXXXX}/datasets/{XXXXXX}/tables/{XXXXXX}')
.then(function (response) {
return response.json();
})
.then(function (myJson) {
</script>
</head>
</html>
It's not feasible to consume a data warehouse in Javascript as you layout.在您布局时使用 Javascript 中的数据仓库是不可行的。
You need to implement a backend that will work with the BigQuery API (do the authentication, run the query), and for your frontend page, the backend will return the results.您需要实现一个可与 BigQuery API 一起使用的后端(进行身份验证,运行查询),对于您的前端页面,后端将返回结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.