Amazon Translate in Nodejs

0

Hi, I'm trying to set up Amazon Translate on a Nodejs project but I'm getting the following error:

"Error: Credential is missing
    at SignatureV4.credentialProvider (http://localhost:3000/static/js/vendors~main.chunk.js:8000:29)
    at SignatureV4.<anonymous> (http://localhost:3000/static/js/vendors~main.chunk.js:11884:20)
    at step (http://localhost:3000/static/js/vendors~main.chunk.js:320095:17)
    at Object.next (http://localhost:3000/static/js/vendors~main.chunk.js:320026:14)
    at http://localhost:3000/static/js/vendors~main.chunk.js:319999:67
    at new Promise (<anonymous>)
    at __awaiter (http://localhost:3000/static/js/vendors~main.chunk.js:319978:10)
    at SignatureV4.signRequest (http://localhost:3000/static/js/vendors~main.chunk.js:11876:67)
    at SignatureV4.<anonymous> (http://localhost:3000/static/js/vendors~main.chunk.js:11730:18)
    at step (http://localhost:3000/static/js/vendors~main.chunk.js:320095:17)
    at Object.next (http://localhost:3000/static/js/vendors~main.chunk.js:320026:14)
    at http://localhost:3000/static/js/vendors~main.chunk.js:319999:67
    at new Promise (<anonymous>)
    at __awaiter (http://localhost:3000/static/js/vendors~main.chunk.js:319978:10)
    at SignatureV4.sign (http://localhost:3000/static/js/vendors~main.chunk.js:11717:67)
    at http://localhost:3000/static/js/vendors~main.chunk.js:10714:24
    at step (http://localhost:3000/static/js/vendors~main.chunk.js:320095:17)
    at Object.next (http://localhost:3000/static/js/vendors~main.chunk.js:320026:14)
    at fulfilled (http://localhost:3000/static/js/vendors~main.chunk.js:319981:24)"

I tried including the Access Key and Secret in the Translate constructor but still recieving the same error. Does anyone know what I'm missing? Included a sample code below:

var AWS = require("@aws-sdk/client-translate");

var translate = new AWS.Translate({ region: "us-east-1", accessKeyId: "{ACCESS_ID}", secretAccessKey: "{SECRET_KEY}" });

var params = {
SourceLanguageCode: 'auto',
TargetLanguageCode: 'es',
Text: text
};

translate.translateText(params, function(err, data) {
	if (err) {
		console.log(err, err.stack);
		alert("Error calling Amazon Translate. " + err.message);
		return;
	}
	if (data) {
		console.log(data['TranslatedText']);
	}
});

Thank you

Ag Dev
asked a year ago122 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions