0

I'm building a custom rest API endpoint.

This is code which I have written in my custom model class.

return [
   ['success' => false,
   'status-title' => 'Refund Failed',]
];

Following response I'm getting in Postman while my testing the end point.

[
    {
        "success": false,
        "status-title": "Refund Failed"
    }
]

I want to JSON response like following example

{
        "success": false,
        "status-title": "Refund Failed"
}

How Can I set JSON response

{
        "success": false,
        "status-title": "Refund Failed"
}

Instead of following JSON format

[
    {
        "success": false,
        "status-title": "Refund Failed"
    }
]

1 Answer 1

0

Just Modify the the return line code to this :

return ['success' => false, 'status-title' => 'Refund Failed'];

Let me know if it works for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.