I have a simple Express app and I am trying to figure out how to get data from AWS Redshift using the "@aws-sdk/client-redshift-data" module.
Following the example code from the module's GitHub page, I'm doing this:
const {
RedshiftDataClient,
ListSchemasCommand,
} = require("@aws-sdk/client-redshift-data");
const client = new RedshiftDataClient({ region: "eu-central-1" });
console.log(`RedshiftDataClient created :::: ${JSON.stringify(client)}`);
const params = {
/** input parameters */
};
const command = new ListSchemasCommand(params);
try {
const data = await client.listSchemas(command);
// process data.
console.log(`PROCESSING DATA :::: ${JSON.stringify(data)}`);
} catch (error) {
// error handling.
console.log(`LIST SCHEMAS ERROR :::: ${error}`);
}
Source: https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-redshift-data
I'm getting an error saying:
TypeError: client.listSchemas is not a function
It looks like the RedshiftDataClient that I created via the constructor isn't in the expected format. This is what I get when I log it:
{
"middlewareStack": {},
"config": {
"apiVersion": "2019-12-20",
"disableHostPrefix": false,
"extensions": [],
"httpAuthSchemes": [
{
"schemeId": "aws.auth#sigv4",
"signer": {}
}
],
"logger": {},
"serviceId": "Redshift Data",
"runtime": "node",
"requestHandler": {
"metadata": {
"handlerProtocol": "http/1.1"
},
"configProvider": {}
},
"defaultSigningName": "redshift-data",
"tls": true,
"isCustomEndpoint": false,
"systemClockOffset": 0,
"signingEscapePath": true
}
}
It doesn't have 'listSchemas' or any other methods.
What could I be missing here? Thanks
There's a difference between RedshiftDataClient
and RedshiftData
. It looks like you're combining syntax from both.
You either want:
const client = new RedshiftDataClient({});
client.send(new ListSchemasCommand({}))
or
const client = new RedshiftData({});
client.listSchemas({})
https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/introduction/