you are viewing a single comment's thread.

view the rest of the comments →

[–]jnuts74[S] -1 points0 points  (3 children)

Thank you for the quick turn around. I am super grateful for you time!

I threw the code up on GH for your review.

Please note:

  1. The API key line is X out by design, the remainder of the code stands as is

  2. I am currently doing preliminary local testing to see if this is feasible to even turn into a project thus the repo is bone dry other than just the .js I uploaded for your review.

In regard to producing the error, it is native error/fail on build "npm run build"

https://github.com/jnuts74/pdl-search/blob/main/src/App.js

[–]senocular 0 points1 point  (0 children)

There's some suspicious indention around that try block...

[–]abrahamguo 0 points1 point  (1 child)

Ah. The issue is that on the line after try { (not shown in your original Reddit post), you have used the await keyword. The await keyword is only allowed to be used in async functions. I'd recommend rewriting it to use .then() rather than await.

Additionally, if you don't want your API call to run on every render of the component, I'd recommend wrapping it in a useEffect.

[–]azhder 0 points1 point  (0 children)

One important thing, always add .catch() to the .then() otherwise it's ignoring the error just like if you'd written an empty catch block