api-platform / api-platform/create-client

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

未關閉
#382 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
376
分支
132
PR 合併指標
30 天內沒有已合併 PR

描述

**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

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。