- Core API's
- >
- Posts API
- >
- Posts - Delete
Posts - Delete API
Delete the specified Post.
Method DELETE
Parameters
Name | Details | Type | Required |
---|---|---|---|
id
|
The ID of the Post. | integer | Yes |
How to Use
fetch('https://simplecrudapi.com/api/posts/1', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(json => console.log(json))
.catch(error => console.error('Error deleting post:', error));
Response
{
"data": {
"id": 1,
"title": "Updated Post Title",
"content": "Updated content of the post",
"category": {
"id": 1,
"name": "Education",
"description": "Resources and information for lifelong learning"
},
"tags": [
{
"id": 2,
"name": "Innovation",
"description": "Minus vel qui et aut."
},
{
"id": 3,
"name": "Wellness",
"description": "Minus vel qui et aut."
}
],
"created_at": "2024-11-09T12:34:56Z",
"updated_at": "2024-11-09T13:00:00Z"
}
}
Try Now
fetch('https://simplecrudapi.com/api/posts/1', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(json => console.log(json))
.catch(error => console.error('Error deleting post:', error));