SyntaxError: Unexpected token 'catch' in…
- User
SyntaxError: Unexpected token 'catch' in C:\Users\Ilya\Downloads\my-musician-network\views\profile.ejs while compiling ejs
If the above error is not helpful, you may want to try EJS-Lint: https://github.com/RyanZim/EJS-Lint Or, if you meant to create an async function, pass
async: trueas an option. at new Function () at Template.compile (C:\Users\Ilya\node_modules\ejs\lib\ejs.js:673:12) at Object.compile (C:\Users\Ilya\node_modules\ejs\lib\ejs.js:398:16) at handleCache (C:\Users\Ilya\node_modules\ejs\lib\ejs.js:235:18) at tryHandleCache (C:\Users\Ilya\node_modules\ejs\lib\ejs.js:274:16) at exports.renderFile [as engine] (C:\Users\Ilya\node_modules\ejs\lib\ejs.js:491:10) at View.render (C:\Users\Ilya\Downloads\my-musician-network\node_modules\express\lib\view.js:135:8) at tryRender (C:\Users\Ilya\Downloads\my-musician-network\node_modules\express\lib\application.js:657:10) at Function.render (C:\Users\Ilya\Downloads\my-musician-network\node_modules\express\lib\application.js:609:3) at ServerResponse.render (C:\Users\Ilya\Downloads\my-musician-network\node_modules\express\lib\response.js:1039:7)<% if (userLoggedIn && username === musician.name) { %> <a href="/profile/<%= musician.id %>/edit">Edit profile</a> <div id="edit-profile-modal" class="modal"> <div class="modal-content"> <span class="close">×</span> <h2>Edit Profile</h2> <form action="/profile/<%= musician.id %>/edit" method="POST" enctype="multipart/form-data"> <div> <label for="name">Name:</label> <input type="text" id="name" name="name" value="<%= musician.name %>"> </div> <div> <label for="genre">Genre:</label> <input type="text" id="genre" name="genre" value="<%= musician.genre %>"> </div> <div> <label for="instrument">Instrument:</label> <input type="text" id="instrument" name="instrument" value="<%= musician.instrument %>"> </div> <div> <label for="location">Location:</label> <input type="text" id="location" name="location" value="<%= musician.location %>"> </div> <div> <label for="bio">Bio:</label> <textarea id="bio" name="bio"><%= musician.bio %></textarea> </div> <div>SoundCloud:
<div> <label for="thumbnail">Thumbnail:</label> <input type="file" id="thumbnail" name="thumbnail"> </div> <button type="submit">Save</button> </form> </div> </div><% } %> const modal = document.getElementById("edit-profile-modal"); const btn = document.getElementsByTagName("a")[0]; const span = document.getElementsByClassName("close")[0];
btn.onclick = function() { modal.style.display = "block"; } span.onclick = function() { modal.style.display = "none"; } window.onclick = function(event) { if (event.target == modal) { modal.style.display = "none"; } } const musicFields = document.getElementById("music-fields"); - Assistant
It seems that there is an issue with the syntax of the code in the EJS template. Specifically, the error message mentions an unexpected token 'catch'. This likely means that there is an issue with a try/catch block in the code.
To resolve this issue, you can start by checking all try/catch blocks in the code and ensuring that they are properly formatted. You can also try running the code through EJS-Lint to identify any syntax errors. Additionally, you can try passing the 'async: true' option if you intended to create an async function.