Comments Comments API

100 comments linked to posts and users.

Get all comments

Get all comments (paginated).
fetch('https://axomock.fauzantaslim.biz.id/api/comments')
  .then(res => res.json())
  .then(console.log);
axios.get('https://axomock.fauzantaslim.biz.id/api/comments')
  .then(res => console.log(res.data));
curl https://axomock.fauzantaslim.biz.id/api/comments
200 OK
{
  "comments": [
    {
      "id": 1,
      "body": "Great article! I've been using these principles in my projects and they really make a difference.",
      "postId": 1,
      "user": {
        "id": 3,
        "username": "noahb"
      }
    },
    ... // 29 more items
  ],
  "total": 100,
  "skip": 0,
  "limit": 30
}

Search comments

Search comments by body text.
fetch('https://axomock.fauzantaslim.biz.id/api/comments/search?q=great')
  .then(res => res.json())
  .then(console.log);
axios.get('https://axomock.fauzantaslim.biz.id/api/comments/search?q=great')
  .then(res => console.log(res.data));
curl "https://axomock.fauzantaslim.biz.id/api/comments/search?q=great"
200 OK
{
  "comments": [
    ... // array of matched comments
  ],
  "total": 2,
  "skip": 0,
  "limit": 30
}

Get a single comment

Get a single comment by ID.
fetch('https://axomock.fauzantaslim.biz.id/api/comments/1')
  .then(res => res.json())
  .then(console.log);
axios.get('https://axomock.fauzantaslim.biz.id/api/comments/1')
  .then(res => console.log(res.data));
curl https://axomock.fauzantaslim.biz.id/api/comments/1
200 OK
{
  "id": 1,
  "body": "Great article! I've been using these principles in my projects and they really make a difference.",
  "postId": 1,
  "user": {
    "id": 3,
    "username": "noahb"
  }
}

Limit and skip comments

You can pass limit and skip params to limit and skip the results for pagination.
fetch('https://axomock.fauzantaslim.biz.id/api/comments?limit=10&skip=10')
  .then(res => res.json())
  .then(console.log);
axios.get('https://axomock.fauzantaslim.biz.id/api/comments?limit=10&skip=10')
  .then(res => console.log(res.data));
curl "https://axomock.fauzantaslim.biz.id/api/comments?limit=10&skip=10"
200 OK
{
  "comments": [
    ...
  ],
  "total": 100,
  "skip": 10,
  "limit": 10
}

Create a comment

Adding a new comment will not add it into the server. It will simulate a POST request and will return the new created comment with a new id.
fetch('https://axomock.fauzantaslim.biz.id/api/comments', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    body: 'This makes perfect sense!',
    postId: 3,
    userId: 5
  })
})
.then(res => res.json())
.then(console.log);
axios.post('https://axomock.fauzantaslim.biz.id/api/comments', {
  body: 'This makes perfect sense!',
  postId: 3,
  userId: 5
})
.then(res => console.log(res.data));
curl -X POST https://axomock.fauzantaslim.biz.id/api/comments \
-H "Content-Type: application/json" \
-d '{"body":"This makes perfect sense!","postId":3,"userId":5}'
201 Created
{
  "id": 101,
  "body": "This makes perfect sense!",
  "postId": 3,
  "userId": 5
}

Update a comment

Updating a comment will not update it into the server. It will simulate a PUT/PATCH request and will return the updated comment.
fetch('https://axomock.fauzantaslim.biz.id/api/comments/1', {
  method: 'PUT', /* or PATCH */
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    body: 'Actually, I changed my mind.'
  })
})
.then(res => res.json())
.then(console.log);
axios.put('https://axomock.fauzantaslim.biz.id/api/comments/1', {
  body: 'Actually, I changed my mind.'
})
.then(res => console.log(res.data));
curl -X PUT https://axomock.fauzantaslim.biz.id/api/comments/1 \
-H "Content-Type: application/json" \
-d '{"body":"Actually, I changed my mind."}'
200 OK
{
  "id": 1,
  "body": "Actually, I changed my mind.",
  ...
}

Delete a comment

Deleting a comment will not delete it into the server. It will simulate a DELETE request and will return deleted comment.
fetch('https://axomock.fauzantaslim.biz.id/api/comments/1', {
  method: 'DELETE',
})
.then(res => res.json())
.then(console.log);
axios.delete('https://axomock.fauzantaslim.biz.id/api/comments/1')
.then(res => console.log(res.data));
curl -X DELETE https://axomock.fauzantaslim.biz.id/api/comments/1
200 OK
{
  "id": 1,
  "body": "Great article! I've been using these principles in my projects and they really make a difference.",
  ...,
  "isDeleted": true,
  "deletedOn": "2026-07-08T05:42:00.000Z"
}