- Core API's
- >
- Comments API
- >
- Comments - List
Comments - List API
Get all the Comments.
Method GET
Parameters
Name | Details | Type | Required |
---|---|---|---|
page
|
The page number. | integer | No |
query
|
The search query. | string | No |
orderBy
|
The field to order by. | string | No |
orderDirection
|
The order direction. | string | No |
API Example
How to Use
fetch('https://simplecrudapi.com/api/posts/1/comments')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
Response
{
"data": [
{
"id": 1,
"content": "This is a beautifully crafted comment, expressing a thoughtful and engaging response to the post. It highlights key points and adds valuable insight to the conversation.",
"post": {
"id": 1,
"title": "The Future of AI in Education",
"content": "Exploring the impact of artificial intelligence on modern education systems.",
"tags": [
{
"id": 3,
"name": "nostrum",
"description": "Ab nam voluptas rem velit ratione quidem quo."
},
{
"id": 9,
"name": "aut",
"description": "Corrupti soluta provident sapiente soluta."
}
],
"created_at": "2024-11-10T13:58:06.000000Z",
"updated_at": "2024-11-10T13:58:06.000000Z"
}
}
],
"links": {
"first": "http:\/\/127.0.0.1:8000\/api\/posts\/1\/comments?page=1",
"last": "http:\/\/127.0.0.1:8000\/api\/posts\/1\/comments?page=1",
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"links": [
{
"url": null,
"label": "« Previous",
"active": false
},
{
"url": "http:\/\/127.0.0.1:8000\/api\/posts\/1\/comments?page=1",
"label": "1",
"active": true
},
{
"url": null,
"label": "Next »",
"active": false
}
],
"path": "http:\/\/127.0.0.1:8000\/api\/posts\/1\/comments",
"per_page": 20,
"to": 1,
"total": 1
}
}
Try Now
fetch('https://simplecrudapi.com/api/posts/1/comments')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));