“ NetworkingError:网络故障”-React Native中的适用于JavaScript的AWS开发工具包

时间:2020-04-13 17:00:20

标签: android react-native aws-sdk

我正在尝试在 React Native 应用程序中为 JavaScript 使用 AWS SDK

我创建了一个AWS.Comprehend对象,在配置了凭据并调用了detectDominantLanguage方法后,控制台显示了以下错误:

[NetworkingError: Network Failure] Network Failure http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:132243:49
dispatchEvent@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:34133:31
setReadyState@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:33217:33
__didCompleteResponse@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:33044:29
emit@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:3420:42
__callFunction@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2748:49
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2470:31
__guard@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2702:15
callFunctionReturnFlushedQueue@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2469:21
callFunctionReturnFlushedQueue@[native code]

以下代码段显示了如何配置应用程序。为简洁起见,删除了一些代码:

import AWS from 'aws-sdk/dist/aws-sdk-react-native';

AWS.config.update({
    accessKeyId: '#', // the # is just a placeholder, not the real value
    secretAccessKey: '#', // the # is just a placeholder, not the real value
    region: 'sa-east-1'
});

const comprehend = new AWS.Comprehend();

export default class DominantLanguageScreen extends Component {   
    render() {
        comprehend.detectDominantLanguage(params, function (err, data) {
            if (err) 
                console.log(err, err.message, err.stack);       
            else {
                console.log(JSON.stringify(data));
            }
        });

        return (...);
    }
}

我正在物理android设备上运行该应用程序。

0 个答案:

没有答案