Delete the user's avatar image

DELETE /api/profile/deleteavatar

The JWT token in the 'jwt' cookie is verified by the verifyJWT middleware. If valid, the user's ID is extracted from the token and added to request.body.userId. The deleteAvatar controller then handles deleting the user's avatar and returns the response.

Responses

  • 200 application/json

    Avatar deleted successfully

    Hide response attributes Show response attributes object
    • message string
    • deleted boolean
  • 401 text/plain

    Unauthorized, JWT cookie is missing

  • 403 text/plain

    Forbidden, JWT token is invalid

  • 404 text/plain

    User not found

  • 500 text/plain

    Internal server error

DELETE /api/profile/deleteavatar
curl \
 --request DELETE 'http://localhost:xxxx/api/profile/deleteavatar' \
 --cookie "jwt=$API_KEY"
Response examples (200)
{
  "message": "用户头像删除成功",
  "deleted": true
}
Response examples (401)
您未通过身份验证
Response examples (403)
无效的令牌
Response examples (404)
未找到用户错误
Response examples (500)
服务器内部错误