I am migrating S3 client on node.js from v2 to v3. And getting error: Region is missing, when using any command: s3Client.send(\\any command\\);
I have the latest libraries v3.405.0 and initialise S3 with this code:
import { S3Client, ListObjectsV2Command } from "@aws-sdk/client-s3";
async function getData() {
const s3Client = new S3Client([
{
region: "eu-central-1",
accessKeyId: "xx",
secretAccessKey: "xx"
}
]);
const command = new ListObjectsV2Command({
Bucket: "dev-env",
Delimiter: "/",
Prefix: "orders/2022-02/2021000382-284/28/"
});
const data = await s3Client.send(command);
console.log(JSON.stringify(data));
}
getData();
I have tried also in sandbox only the library and getting same error.
Any idea?
There's an extra array in input of your S3 client instantiation.
Here's the correct syntax:
I've integrated this correction in your code, tested with the same library version and it works: