DEV Community

Discussion on: Javascript: How to access the return value of a Promise object

Collapse
 
tomknn profile image
TomKnn

Hi Kate,

Thank you so much for your time and trouble, I appreciate!
I've tried your code but I get this error because of the 'const recipes = await getRecipes()' line:
Uncaught SyntaxError: await is only valid in async functions and the top level bodies of modules

Do you have any suggestions? Api fetch is pretty new to me and my vocabulary with this is limited.

Thread Thread
 
ramonak profile image
Katsiaryna (Kate) Lupachova

could you please DM me or provide me a link to your code somewhere online (github repo, code sanbox and so on), so I could take a look and try to help you?

Thread Thread
 
tomknn profile image
TomKnn

Sure, it`s github.com/TomKnn/EindopdrachtMood....
To give you some context, I'm re-educating from illustrator/'art'teacher to front end developer due to lack of work opportunities. I like it very much but the course is online with little help, I'm stuck for months now on little things.
This is my final assignment where we have to a modest site design with an api function.
It's a bit of a mess, but I'll tweak it as soon as my code works.
The files you need are here github.com/TomKnn/EindopdrachtMood...
And here is the main.js where I want to import the function.
github.com/TomKnn/EindopdrachtMood...

Pls let me know if something is unclear, many thanks!!
Tom