Skip to content

json-api-response-converter throwing RangeError: Maximum call stack size exceeded #5

@flyingboy007

Description

@flyingboy007

Below is the response I receive from backend(using fastjsonapi serializer)

{
  "data": {
    "id": "12",
    "type": "seller_vertical",
    "attributes": {
      "aasm_state": "created",
      "created_at": "2020-04-16T10:06:56.041Z",
      "updated_at": "2020-04-16T10:06:56.041Z"
    },
    "relationships": {
      "documents": {
        "data": [
          {
            "id": "62",
            "type": "document"
          }
        ]
      }
    }
  },
  "included": [
    {
      "id": "62",
      "type": "document",
      "attributes": {
        "name": "test file",
        "status": "unverified",
        "approval_status": {
          "has_review_pending_data": true,
          "review_pending_data": {
            "id": 62,
            "is_delete": false,
            "document_notes": [],
            "document_status": "pending_verification"
          }
        }
      },
      "relationships": {
        "attachments": {
          "data": [
            {
              "id": "18",
              "type": "attachment"
            },
            {
              "id": "19",
              "type": "attachment"
            }
          ]
        }
      }
    },
    {
      "id": "18",
      "type": "attachment",
      "attributes": {
        "image_url": "some_url",
        "expiry_date": null,
        "status": "pending"
      },
      "relationships": {
        "document": {
          "data": {
            "id": "62",
            "type": "document"
          }
        }
      }
    },
    {
      "id": "19",
      "type": "attachment",
      "attributes": {
        "image_url": "some_url",
        "file_name": "unnamed.jpg",
        "expiry_date": null,
        "status": "pending"
      },
      "relationships": {
        "document": {
          "data": {
            "id": "62",
            "type": "document"
          }
        }
      }
    }
  ]
}

Here the seller_vertical object has_many documents.
Similarly each document has_many attachments.
But when I do
const formattedData = new JsonApiResponseConverter(data).formattedResponse

I am getting error

Exception: RangeError: Maximum call stack size exceeded at eval (webpack-internal

I created a sandbox with the error
working sample

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions