Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用 renderJson 和 renderHtml 会有回环的 json 无法序列化 #35

Closed
CheneyWong opened this issue Sep 25, 2020 · 2 comments
Closed

Comments

@CheneyWong
Copy link

我这么用的

app.get('/', async function (req, res) {
        const ret = await renderer.renderHtml()
        console.log( ret )
        res.send(ret)
    });

在 send 发送的时候报错:

(node:21428) UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'SSR'
    |     property 'plugin' -> object with constructor 'PluginManage'
    |     property 'plugins' -> object with constructor 'Array'
    |     index 0 -> object with constructor 'InstallPlugin'
    --- property 'ssr' closes the circle
    at JSON.stringify (<anonymous>)

返回给前端的 json 格式是什么标准,必须配合 genesis-remote 来使用么?
需要我自己解决回环问题?自己拆解回环了前端可能还原不回来了。

@lzxb
Copy link
Contributor

lzxb commented Sep 26, 2020

你应该返回的是ret.data

@lzxb
Copy link
Contributor

lzxb commented Sep 26, 2020

他返回的对象是

    interface RenderResultHtml {
        type: 'html';
        data: string;
        context: RenderContext;
    }

@lzxb lzxb closed this as completed Sep 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants