Skip to content

Mapping multiple entities from one response #177

@ivan006

Description

@ivan006

How do I map multiple entities types from a single response?
Say for instance I hit a user_with_tasks endpoint which returns me a user but all their tasks also. What would I use to map to both models. I found some code somewhere that shows I would use "dataTransformer" and then inside use

data.tasks.map((task) => {
     Object.assign(task);
     Object.assign(task.attributes);
});

does this look right? I might be completely misunderstanding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions