3

I have set up AWS Amplify in an Angular 7 project using the API module for GraphQL capabilities.

All seems to work when served using ng serve.

If however if I use AOT compilation - e.g. For a production build then I receive no compilation errors but on runtime I see the following error

ERROR Error: Uncaught (in promise): ReferenceError: API is not defined

I have isolated the problem in that AOT is the trigger for it occurring but unsure whether it is an Amplify issue or something silly I am doing regarding Angular.

What am I doing wrong and how can I resolve it?

nyedidikeke
  • 6,899
  • 7
  • 44
  • 59

1 Answers1

0

For anyone else with this issue try prefixing API with Amplify.API. Not sure why it worked with JIT but not AOT but it solved the problem for me.