- Core API's
- >
- Comments API
- >
- Comments - Update
Comments - Update API
Update the specified Comment.
Method PUT
Parameters
Name | Details | Type | Required |
---|---|---|---|
id
|
The ID of the Comment. | integer | Yes |
Body
{
"name": "string",
"email": "string",
"body": "string",
"post_id": 1
}
How to Use
fetch('https://simplecrudapi.com/api/comments/1', {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
'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
})
})
.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"
}
}
}
Try Now
fetch('https://simplecrudapi.com/api/comments/1', {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
'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
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error))