question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stringify Vue instance

See original GitHub issue

Version

2.6.10

Reproduction link

https://codesandbox.io/s/vue-stringify-instance-2h78n

Steps to reproduce

Open the link, the error is reproduced right away as the code tries to serliaze the Vue instance.

What is expected?

Being able to serlialize the Vue instance.

What is actually happening?

Is not possible as the Vue prototype is missing the toJSON method.


The code is using telejson as the stringify library in order to remove circular references. Is the same utility used by Storybook 5 which will rise those errors in diferent scenarios, as for example when using the Action addon and passing as argument a Vue instance.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
AlbertMarashicommented, Jun 23, 2019

This can be implemented in userland, I’m sure there’s uses for this, but most users won’t need to use this.

This would be better implemented as a plugin or library

1reaction
AlbertMarashicommented, Jun 23, 2019

You can’t really serialise functions (computed, methods etc), VUE relies on them to work.

If you need to serialise your vue app, you may be doing something wrong. Data can be serialised, and you can have a method for that, which can integrate with your API, but it’s not easily possible to serialise a vue instance, there would be too many edge cases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue stringify instance - CodeSandbox
CodeSandbox is an online editor tailored for web applications.
Read more >
Vue.js JSON Stringify - Method JavaScript | VueJS Example
We can use native JavaScript JSON stringify() method to convert json object to json string. Here in this tutorial, we are going to...
Read more >
Vue data not available until JSON.stringify() is called
After working on the problem with a friend, I found the underlying issue being a JavaScript-specific one involving Vue's reactive nature.
Read more >
Strange behavior w/ JSON.stringify Vue 3 - Get Help
My component parses URL parameters to use in a fetch call. When I print the payload inside the fetch function, the object is...
Read more >
How To Use JSON.parse() and JSON.stringify() - DigitalOcean
parse() takes a JSON string and transforms it into a JavaScript object. let userStr = '{"name":"Sammy","email":"sammy@example.com" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found