I am working on Google BigQuery . i want to upload data to BigQuery Table from node.js . but i am facing a trouble here . when i send my json data form node.js app to insert that data in bigQuery table by using this code
line = {"id":"123", "dttme":"201807012130", "brwsr":"Chrome", "pg_id":"hpv1"};
const datajson=line;
const {BigQuery} = require('@google-cloud/bigquery');
const TableObjectHeader = {
"tableReference": {
"projectId": "local-bebop-277417",
"datasetId": "local-bebop-277417:123",
"tableId": "local-bebop-277417:123.first",
}
}
const bigqueryClient = new BigQuery();
const dataset = bigqueryClient.dataset(TableObjectHeader['tableReference']['datasetId']);
const table = dataset.table(TableObjectHeader['tableReference']['tableId']);
table.insert(datajson, function(err, response) {
console.log("error:"+JSON.stringify(err));
console.log("response:"+JSON.stringify(response));
});
then in console i am getting
error:{}
response:undefined
and i am not getting my datajson in BigQuery Tble ? Can any one help me how to fix this problem ?