4

I'm looking for some help on my textract client project. I am trying to follow the AWS Textract documentation, but I am stuck at the textractClient.send(). I am getting the error URL.hostname is not implemented

I have followed the steps on AWS to set up my IAM, S3, and I have updated my ~/.aws/config and credentials files. I left out a couple of fields but here's my code:

import { AnalyzeExpenseCommand } from  "@aws-sdk/client-textract";
import  { TextractClient } from "@aws-sdk/client-textract";
...
const textractClient = new TextractClient({ region: 'us-east-1' });

const bucket = 'scannsplit-s3-bucket'
const photo = 'Sojuba.png'

// Set params
const params = {
    Document: {
        S3Object: {
            Bucket: bucket,
            Name: photo
        },
    },
}
...
const process_text_detection = async () => {
    try {
        const aExpense = new StartExpenseAnalysisCommand(params);
        console.log(aExpense);
        const response = await textractClient.send(aExpense);
        console.log(response);
        return response; // For unit tests.
     } catch (error) {
        console.log('Error: ' + error);
    }
}
...
process_text_detection() is being called with a button

What I've tried: I came across this other post Error "URL.hostname is not implemented", AWS SNS in React Native Android that seems to have a similar issue. I tried the solution and after I installed react-native-url-polyfill and react-native-get-random-values, I got the error Native module is not found. I tried looking for fixes for that error but also did not have much luck.

Any help is much appreciated.

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
Jackc01999
  • 41
  • 3
  • This worked for me - see the top response. https://stackoverflow.com/questions/70413410/error-url-hostname-is-not-implemented-aws-sns-in-react-native-android – mjmostachetti Jul 08 '22 at 15:03

0 Answers0