«NetworkingError: Ошибка сети» - AWS SDK для JavaScript в React Native - PullRequest
0 голосов
/ 13 апреля 2020

Я пытаюсь использовать AWS SDK для JavaScript в React Native приложении.

Я создал объект 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 устройстве.

...