Latra
Latra

Reputation: 522

s3 getdata is not returning anything on Alexa-Hosted(Node Js)

I'm trying to create an Alexa Skill on the Alexa Developer Console (using Alexa Hosted) and I want to recover a file from the bucket.

I created the file successfully, but when I try to recover it is not returning anything and I don't see any kind of error in the logs.

That's my code:

async function getGameData(key)
{
    const params = {
        Bucket: BUCKET,
        Key: key
    };
    const respose = await S3.getObject(params, (err => {
        if(err) {
            console.log('Error recovering the file')
        }
    }))
    return respose.Body;
}

and there are my logs: logs

Thanks for the help :D

Upvotes: 1

Views: 124

Answers (1)

Joey Kilpatrick
Joey Kilpatrick

Reputation: 1602

In the AWS SDK for Javascript, S3.getObject does not return a promise. You must use .promise().

let response;
try {
    response = await S3.getObject(params).promise();
} catch (e) {
    console.log('Error recovering the file');
}

Upvotes: 2

Related Questions