title: Invoke Lambda function from Amplify-generated React App without using API Gateway
body: <p>I used <a href="https://aws-amplify.github.io/docs/js/start?platform=react" rel="noreferrer">Amplify</a> to generate a static website and the underlying React app. Initially I also generated an API endpoint but, because my lambda function may run over the API Gateway timeout limit (29 seconds), I need to invoke the lambda function directly from the generated React App, instead of going through API Gateway.</p>
  
  <p>The code looks as follows, for the React page to authenticate using Cognito:</p>
  
  <pre><code>import Auth from '@aws-amplify/auth';
  import { withAuthenticator } from 'aws-amplify-react';
  import awsconfig from './aws-exports';
  
  Auth.configure(awsconfig);
  </code></pre>
  
  <p>The above lines wrap the App (root) object and work as advertised. But since I do not want to use the API Gateway, how do I invoke the AWS Lambda function directly from React App? </p>
  
  <p>The <a href="https://stackoverflow.com/a/33662803/4332644">answers</a> I could find talk about importing AWS etc, which seems to be in conflict with what we are trying to do here. I need to use the authenticated connection (which already works using the above code) when invoking lambda, so I cannot use generic invocation given in this example. </p>
  
  <p>The <a href="https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html" rel="noreferrer">Invoke API</a> does not provide any examples as well.</p>
  
  <p>Any advice is appreciated.</p>