I was trying to creat a website with following a video. But at the end i got an issue. i tried write it like ” ({ note,id })” and erors gone but in my website when i tried to delete the note it doesn’t work anymore. I can’t see where is the problem the problem.
{% extends "base.html" %} {% block title %}Home{% endblock %} {% block content
%}
<h1 align="center">Notes</h1>
<ul class="list-group list-group-flush" id="notes">
{% for note in user.notes %}
<li class="list-group-item">
{{ note.data }}
<button type="button" class="close" onClick="deleteNote({{ note.id }})">
<span aria-hidden="true">×</span>
</button>
</li>
{% endfor %}
</ul>
<form method="POST">
<textarea name="note" id="note" class="form-control"></textarea>
<br />
<div align="center">
<button type="submit" class="btn btn-primary">Add Note</button>
</div>
</form>
{% endblock %}
and this is my js code.
function deleteNote(noteId) {
fetch("/delete-note", {
method: "POST",
body: JSON.stringify({ noteId: noteId }),
}).then((_res) => {
window.location.href = "/";
});
}
these are my error messages.
[{
"resource": "/c:/flaskweb/website/templates/home.html",
"owner": "_generated_diagnostic_collection_name_#1",
"severity": 8,
"message": "Property assignment expected.",
"source": "javascript",
"startLineNumber": 8,
"startColumn": 64,
"endLineNumber": 8,
"endColumn": 65
}]
[{
"resource": "/c:/flaskweb/website/templates/home.html",
"owner": "_generated_diagnostic_collection_name_#1",
"severity": 8,
"message": "',' expected.",
"source": "javascript",
"startLineNumber": 8,
"startColumn": 70,
"endLineNumber": 8,
"endColumn": 71
}]
[{
"resource": "/c:/flaskweb/website/templates/home.html",
"owner": "_generated_diagnostic_collection_name_#1",
"severity": 8,
"message": "',' expected.",
"source": "javascript",
"startLineNumber": 8,
"startColumn": 75,
"endLineNumber": 8,
"endColumn": 76
}]