Nuxt.js: NuxtServerError: Cannot stringify a function

Created on 1 Oct 2018  路  5Comments  路  Source: nuxt/nuxt.js

Version

v2.1.0

Reproduction link

https://github.com/pimlie/nuxt-issues

Steps to reproduce

clone repro & run yarn dev & browse to http://localhost:3000

What is expected ?

A page that says hello is displayed

What is actually happening?

An error 'NuxtServerError: Cannot stringify a function' occures

Additional comments?

This is due to #3913, serialize could serialize functions but devalue cant. Although I can fix my project to not return a method, this is actually a breaking change.

This bug report is available on Nuxt community (#c7880)
bug-report

All 5 comments

Where now used devalue, there was serialize with isJson which wasnt serializing functions, it was skipping them. And in store there should be only serializable data.

This is not store, but asyncData. Anyway, will regard as a feature then ;)

@pimlie So how did you fix this issue? I am facing the same one

In my case I returned a closure function in asyncData, the solution was to just move that closure definition to data instead. (it was actually some configuration of a graph which had no real use there to begin with).

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VincentLoy picture VincentLoy  路  3Comments

maicong picture maicong  路  3Comments

vadimsg picture vadimsg  路  3Comments

pehbehbeh picture pehbehbeh  路  3Comments

surmon-china picture surmon-china  路  3Comments