How can format JSON repsonse in Loopback like CakePHP response?

12 views
Skip to first unread message

Ha Le

unread,
Apr 19, 2018, 11:29:34 PM4/19/18
to LoopbackJS
I want to convert back-end API  from CakePHP to Loopback, I try to convert some models that have relations, but they do not return JSON like CakePHP. I want to keep CakePHP JSON format but I don't know how to do that in Loopback. Does anyone know how can change format response JSON like CakePHP as below:
 {
        "Task": {
            "id": "1",
            "user_id": "13",
            "project_id": "2",
            "created": "2017-03-06 15:03:27",
            "modified": "2017-03-06 15:03:27",
            "is_deleted": false
        },
        "Project": {
            "id": "2",
            "project_name":"Hitara Farmer",
            "status": "On-progress",
            "description": null
        },
        "User": {
            "id": "13",
            "email": "us...@example.com",
            "first_name": "John",
            "last_name": "Doe",
            "fullname": "John Doe",
            "mobile_no": "024570000",
            "status": "1",
            "picture": "Cornelia.jpg",
            "is_deleted": false,
            "team": null,
            "company": null,
            "contact_id": null,
            "modified": "2017-03-21 08:50:51",
            "created": null,
        }
}

Thanks,
Ha Le
Reply all
Reply to author
Forward
0 new messages