TryGhost/Ghost · warning · Error
Failed to like comment
Error message
Failed to like comment
What it means
comments.like() POSTs to /members/api/comments/{comment.id}/like to register a like. It returns the literal string 'Success' on res.ok, or throws this error on non-ok. No body is sent. This is an idempotent-style action but the backend distinguishes first-like from already-liked states.
Source
Thrown at apps/comments-ui/src/utils/api.ts:282
return res.json();
} else {
throw new Error('Failed to read comment');
}
});
},
like({comment}: {comment: {id: string}}) {
const url = endpointFor({type: 'members', resource: `comments/${comment.id}/like`});
return makeRequest({
url,
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
}).then(function (res) {
if (res.ok) {
return 'Success';
} else {
throw new Error('Failed to like comment');
}
});
},
unlike({comment}: {comment: {id: string}}) {
const body = {
comments: [comment]
};
const url = endpointFor({type: 'members', resource: `comments/${comment.id}/like`});
return makeRequest({
url,
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
}).then(function (res) {
if (res.ok) {
return 'Success';View on GitHub (pinned to 47d8b0e2ad)
Solutions
- Check the Network tab POST response status and body.
- Optimistically update the UI but roll back on error; disable the button during the request to prevent double-submits.
- If 401, prompt re-authentication; if 404, remove the comment locally.
- Handle 'already liked' (if the backend returns it distinctly) by syncing to the liked state rather than showing an error.
Defensive patterns
Strategy: try-catch
Try / catch
// optimistic UI with rollback
setLiked(true);
try {
await api.comments.like({comment});
} catch (e) {
setLiked(false); // roll back
if (e instanceof Error && e.message === 'Failed to like comment') {
// re-auth or inform user
}
} Prevention
- Disable the like button during the POST to prevent double-clicks and 429s.
- Use optimistic UI with rollback so the user sees immediate feedback.
- Handle 401 by re-establishing the member session before retrying.
When it happens
Trigger: The POST returns 4xx/5xx. The member is not authenticated (401), already liked the comment (may be 409 or 400 depending on backend), the comment was deleted (404), the member is banned (403), or rate limiting applies (429).
Common situations: A member double-clicks the like button and the second request conflicts. A member's session expired and the like silently fails. The comment was removed by a moderator but the button is still rendered.
Related errors
- Failed to unlike comment
- Failed to dislike comment
- Failed to undislike comment
- Failed to fetch site data
- Failed to fetch comments
AI-assisted analysis of TryGhost/Ghost@47d8b0e2ad (2026-08-13).
Data as JSON: /api/errors/09d03ea9431b422b.
Report an issue: GitHub.