问题
I'm have a ReactJS application that uses the aws-sdk for cognito login. I used yarn
to install all modules, but when I try to access the website at localhost I get a JS error: Uncaught (in promise) TypeError: STS is not a constructor.
The error points to this line in the aws-sdk
credentials file:this.sts = this.sts || new STS(clientConfig);
Where STS
is from: var STS = require('../../clients/sts');
Any thoughts on how to resolve this error? I've tried installing other modules or upgrading them, but continue to get this error.
EDIT - VUE.js EXAMPLE:
import {
Config as AWSConfig,
CognitoIdentityCredentials,
} from 'aws-sdk/global';
import LexRuntime from 'aws-sdk/clients/lexruntime';
import Polly from 'aws-sdk/clients/polly';
回答1:
I think new STS(...)
gives you such error of STS in not a constructor
.
Please get rid of new
operator from it:
this.sts = this.sts || STS(clientConfig);
来源:https://stackoverflow.com/questions/52831576/aws-js-sdk-typeerror-sts-is-not-a-constructor