Closed simon-zhangmuye closed 3 years ago
TypeError: AWS object not present or incorrect in the constructor
Trying to understand your use case here. A react app is meant for browsers (i.e. anyone on the internet can read the contents of the react app) and hence its usually not a good idea to embed middleware like athena-express directly within the react app. Since invoking athena-express, requires passing an authenticated aws object, you risk exposing your aws credentials through the react app on the internet.
What you can do instead is separate out the 2 pieces: (1) AthenaExpress that is hosted on a server or FaaS (e.g. on an EC2 or Lambda if using AWS) and (2) Your react app that is hosted on a separate server (another EC2 or S3 if using AWS). And then you connect the 2 using APIs.
Happy to chat more and help you through this.
I can use AWS amplify to deploy the source code to AWS. So there is no risk of exposing my aws credentials.
I just get confused. Why there is no Athena object in a browser but works in a standalone js file?
Can you fix this problem and let me to use athena express in React project?
Athena does not support browser access.
Trying to understand your use case here. A react app is meant for browsers (i.e. anyone on the internet can read the contents of the react app) and hence its usually not a good idea to embed middleware like athena-express directly within the react app. Since invoking athena-express, requires passing an authenticated aws object, you risk exposing your aws credentials through the react app on the internet.
What you can do instead is separate out the 2 pieces: (1) AthenaExpress that is hosted on a server or FaaS (e.g. on an EC2 or Lambda if using AWS) and (2) Your react app that is hosted on a separate server (another EC2 or S3 if using AWS). And then you connect the 2 using APIs.
Happy to chat more and help you through this.
When you call it from a standalone js file, it works. Then you try to move it in React, it cannot find Athena Object. Can anyone fix this problem?