How return a JSON response instead of an HTML error code like 401 or 400

Hello guys, i need help

with following the tutorial in this link ‘Implementing JSON Web Token (JWT) Authentication using Spring Security | A Detailed Walkthrough | by Sayan Das | Geek Culture | Medium’, i can create jwt token authorization but how to return json response instead of an HTML error code like 401 or 400 when the JWT token is not valid, expired, or not used ?

That is not really a Postman question, and will be down to how the API and web server is implemented.

As far as I’m aware, if the request is not valid, it should always return a friendly HTML page instead of JSON.

This is probably a question that you need to aim at a Spring Boot/Spring Security forum if one exists.

thank you for your response and suggestion