【问题标题】:Trying to configure throws error尝试配置抛出错误
【发布时间】:2018-03-25 01:57:03
【问题描述】:

我对用于 react 的 aws-sdk 感到困惑,尝试配置它会引发错误,这有点令人困惑,考虑到该对象在调试器中看起来不错,但当我跨过它时会引发错误:TypeError: Unable to get property 'config' of undefined or null reference

代码:

import {AWS, CustomEvent, AMA} from 'aws-sdk';

class App extends Component {
    constructor(props) {

    debugger;
    AWS.config.region = 'us-east-1';
    ...

我假设一旦导入 AWS 包含的配置对象,如果我要附加调试器(在 debugger; 行),AWS 对象看起来不错,AWS.config 和进一步的 AWS.config.region 也是设置为null,但如果我踏步,它会引发上述错误....有什么想法可能配置错误吗?

【问题讨论】:

    标签: reactjs npm aws-sdk-js


    【解决方案1】:

    我遇到了同样的问题,我解决了:

    import AWS from 'aws-sdk';
    
    AWS.config.region = 'us-east-1';
    

    由于某种原因,导致错误的是 import { AWS } 而不是 import AWS

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-02
      • 2021-01-22
      • 1970-01-01
      • 2023-04-04
      • 2018-01-13
      • 2021-11-25
      • 2018-06-30
      相关资源
      最近更新 更多