KoteiIto / node-athena

a nodejs simple aws athena client
MIT License
105 stars 73 forks source link

Using client library with Angular #55

Open garethquirke opened 4 years ago

garethquirke commented 4 years ago

Hi, Trying to use this client with angular project and running into several issues.

const { athena } = require('athena-client');

@Injectable({
  providedIn: 'root'
})
export class AthenaTestGqService {

  clientConfig = {
    bucketUri: constants.aws.athena.tempLocation
  };

  awsConfig = {
    region: constants.aws.region
  };

  constructor() {

    const client = athena.createClient(this.clientConfig, this.awsConfig);

    client.execute('SELECT * FROM my_table LIMIT 20', function (err, data) {
      if (err) {
        console.log(err);
      }
      console.log(data);
    });

  }
}

The error this produces is

TypeError: Cannot read property 'createClient' of undefined

KoteiIto commented 4 years ago

Here is the correct import .

const { createClient } = require('athena-client');
...
const client = createClient(this.clientConfig, this.awsConfig);

or

const athena = require('athena-client');
...
const client = athena.createClient(this.clientConfig, this.awsConfig);