AWS JS SDK TypeError: STS is not a constructor

人走茶凉 提交于 2019-12-11 10:31:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!