1

I have two models with a many-to-many relationship:

  • Blog
  • Tag

So each blog has a tags property, and each tag has a blogs property. I also have two API endpoints: /blogs and /tags

My problem is, if I include and embed the models in the serializer, I got a circular reference with error message "Maximum call stack size exceeded"

Mirage REPL

I'd like to see something like this:

GET /api/blogs
[
  {
    "id": "1",
    "title": "Some title",
    "author": "Author 0",
    "tags": [
      {
        "id": "1",
        "name": "Tag 0"
      },
      {
        "id": "2",
        "name": "Tag 1"
      }
    ]
  }
]

GET /api/tags
[
  {
    "id": "1",
    "name": "Tag 0",
    "blogs": [
      {
        "id": "1",
        "title": "Some title",
        "author": "Author 0"
      }
    ]
  },
  {
    "id": "2",
    "name": "Tag 1",
    "blogs": [
      {
        "id": "1",
        "title": "Some title",
        "author": "Author 0"
      }
    ]
  }
]
KDani
  • 358
  • 4
  • 19
  • 1
    Yes, according to my experience people don't like the long and complicated questions here :) If you are interested, I moved the same question to here: https://www.reddit.com/r/dotnet/comments/liactg/how_to_auth_spa_frontend_and_net_core_backend_api/ – KDani Feb 12 '21 at 13:34
  • 1
    Thanks for let me know, you immediately got feedback that is nice :) – dreamcrash Feb 12 '21 at 13:37

0 Answers0