I've been looking into putting info submitted on google forms into bigquery, so I've been using cloud functions as a way to connect them. However, when I import, I've been getting this error:
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
"TypeError: BigQuery is not a constructor"
I haven't been able to find any solutions to try since most of what I've found online has been old threads where people forget to add the curly braces around {BigQuery}. Any help or ideas would be greatly appreciated! For reference, here's the full code I've been using.
index.js
'use strict';
function main(name) {
// Import the Google Cloud client library
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
}
exports.upload = (req, res) => {
main(req.body.name);
};
package.json
{
"name": "bigquery-load-job",
"version": "0.0.1",
"private": true,
"license": "Apache-2.0",
"engines": {
"node": ">=8.0.0"
},
"scripts": {
"test": "./node_modules/.bin/mocha --reporter spec"
},
"dependencies": {
"@google-cloud/bigquery": "^1.3.0",
"@google-cloud/storage": "1.6.0",
"mocha": "^6.2.0"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.3.0",
"ava": "^2.2.0",
"proxyquire": "2.0.0",
"semistandard": "^12.0.1",
"sinon": "4.4.2"
},
"cloud-repo-tools": {
"requiresKeyFile": true,
"requiresProjectId": true
}
}