Parsing Included Associations from JSON API response - Rails API, AMS, Vue.js SPA
You can parsing a response object manually:
// User response from server:const user = { "id": "1", "type": "users", "attributes": { "name": "John Doe" }, "included": [ { "id": "2", "type": "roles", "attributes": { "name": "Admin" } } ]};// Manually parsing a User response object:user.id; // 1user.attributes.name; // John Doeuser.included.filter(obj => obj.type === 'roles')[0].attributes.name; // Admin
Or, you can use JSONAPI Suite: https://jsonapi-suite.github.io/jsonapi_suite/js/home
first you should fix your serializer
your relation has_many :children
it's wrong you should fix it with has many :childrens
because you has many childrens not children!!!
second you can change include relations and change show defination
def show area = Area.friendly.find(params[:id]) render jsonapi: area, include: %w(childrens, parent)end
probably it's work!!!