I know that this post isn't about async/about but I couldn't help it. You create an async function but don't use await anywhere still working directly with promises. Either make it a normal function or use await:
async/about
async
await
const sendLike = async () => { isDisabled.value = true; likes.value++; try { // ↓ hardcoded postId, yikes await fetch('/api/post/1/likes', { method: 'POST' }) } catch (e) { likes.value--; } finally { isDisabled.value = false; } }
Also, you should move this function to useLikes.js since it's part of the same feature set.
useLikes.js
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I know that this post isn't about
async/about
but I couldn't help it.You create an
async
function but don't useawait
anywhere still working directly with promises. Either make it a normal function or useawait
:Also, you should move this function to
useLikes.js
since it's part of the same feature set.