API Blogs Management
This section provides details on managing blog categories, allowing administrators and users to organize content effectively. Categories help classify blog posts and make navigation easier
API Calls
- Fetch paginated blogs:
fetchPaginatedBlogs
- Fetch total blog count:
fetchTotalBlogs
- Search blogs:
searchBlogs
- Search blogs count:
searchBlogsCount
- Delete a blog:
handleDelete
API Documentation
1. Get Paginated Blogs
Endpoint: /blog/latest-blogs
Method: POST
Description: Retrieves a paginated list of blogs.
Request Body:
Response:
2. Get Total Blog Count
Endpoint: /blog/all-latest-blogs-count
Method: POST
Description: Retrieves the total count of blogs.
Response:
3. Search Blogs
Endpoint: /blog/search
Method: POST
Description: Searches blogs by title or description.
Request Body:
Response:
4. Delete a Blog
Endpoint: /blog/delete
Method: POST
Description: Deletes a blog by its blog_id
.
Request Body:
Response:
5. Get Blog Details
Endpoint: /blog/details
Method: POST
Description: Retrieves details of a single blog.
Request Body:
Response:
Usage Flow
- The admin accesses the Blogs Management page.
- The component fetches paginated blog data from
/blog/latest-blogs
. - The admin can search for blogs by entering a query.
- The admin can delete a blog by clicking the delete button, triggering a request to
/blog/delete
. - A toast notification confirms success or failure of deletion.
Error Handling
- Invalid blog ID: Returns
404 Not Found
- Unauthorized request: Returns
403 Forbidden
- Server errors: Returns
500 Internal Server Error
Conclusion
The Blogs Management panel ensures seamless administration of blog posts, providing an efficient way to search, filter, and moderate content. The API endpoints facilitate dynamic control over blog operations.