How to display detail response from a post API call in java script [closed]

I am calling an API using following body

{
    "x" : "aaa",
    "y" : "bbb",
    "z" : "ccc",
}

in case the API validation failed I get 400 error in the following JSON format

{
    "status": 400,
    "type": "InvalidServiceRequest",
    "message": "Invalid request",
    "detail": "This should be displayed to the user"
}

My question is how can I display the “detail” to the user providing incorrect values?

Leave a Comment