Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

"Cannot stringify arbitrary non-POJOs" error in Nuxt projects

Đang mở
#382 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
nuxtjs, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Tái hiện lỗi bằng lệnh trình tạo Nuxt và trang Animal được tạo. Kiểm tra nuxt.config.js, ./nuxt/stores/animal/list.ts và ./composables/api.ts, đồng thời so sánh các workaround payload và shallowRef được đề xuất. Được xem là hoàn tất khi một client Nuxt 3.4+ được tạo có thể tải tài nguyên mà không gặp lỗi “Cannot stringify arbitrary non-POJOs”.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

API Platform version(s) affected: 3.2.18

Description
Clients generated for Nuxt will fail with: "Cannot stringify arbitrary non-POJOs"

How to reproduce

  • Create an Entity e.g. "Animal"
  • Create a Nuxt project
  • Create a client (e.g. yarn create @api-platform/client https://localhost/ . --generator nuxt --resource animal )
  • Load https://localhost/animal
    You'll get a message saying: "Cannot stringify arbitrary non-POJOs"

Possible Solution

  • One solution is to edit nuxt.config.js and add the following:
  experimental: {
    renderJsonPayloads: false,
  },
  • Another possible solution is to edit ./nuxt/stores/animal/list.ts and add shallowRef() to setHubUrl function:
setHubUrl(hubUrl?: URL) {
      this.hubUrl = shallowRef(hubUrl);
    },
  • Another solution is to edit ./composables/api.ts and add shallowRef() to all onResponse()` functions.

Additional Context
This is occurring with all projects using Nuxt 3.4 or later.
More info at: https://nuxt.com/blog/v3-4#payload-enhancements

Ngôn ngữ chính
TypeScript
Star
376
Fork
132
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của api-platform/create-client

Tất cả issue của api-platform/create-client

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.