Function Signature
src/lib/actions/message/deleteMessage.ts:9
Parameters
Previous state object returned from the last invocation. Used by React’s
useActionState hook.Form data containing the message identifier
Return Value
Validation
This function performs simple validation without Zod:Behavior
- Validation: Checks that the ID field is present
- API Call: Makes a POST request to
{BACKEND_URL}/messages/delete-one/{id} - Authentication: Uses Basic Auth with environment credentials
- Revalidation: Calls
revalidatePath("/")on success to refresh the home page - Error Handling: Returns structured error messages with
success: falseflag
Usage Example
Alternative Usage with FormAction
Backend Endpoint
POST/messages/delete-one/:id
Headers:
Authorization: Basic authentication
Note on Error Responses
UnlikecreateMessage and updateMessage, this function explicitly sets success: false in error responses, making it easier to check the operation status without relying solely on the presence of an error message.