After following the tutorial on building the To Do List, I am experiencing an error where the console is reporting: Uncaught SyntaxError:** import declarations may only appear at top level of a module**. The JS stops right there at the top, and no connection is made to the API. Everything else looks perfect…Can any on help with a clue?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello there.
This error usually means that there is a statement before an import. Imports must necessarily be before any kind of assignment or declaration.
I would recommend that you try adding type="module" to your script tag like this:
<script src="app.js" type="module"></script>
I hope that this helps. Let me know if it fixes your error.
Regards, Boyan
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.