Question: I'm trying to create a Reactive Form with angular 2 so that if the user were to refresh the page, or even come back days later, the form they were working on would still be filled out as they filled it out earlier. I'd like to store this form in local storage.

I tried doing something like ,

```
localStorage.setItem('form', JSON.stringify(this.myFormArray))

```

Where `this.myFormArray` is an array of forms.

However, when I do this, I get an error saying ...

```
RROR TypeError: Converting circular structure to JSON
at Object.stringify (<anonymous>)

```

Any ideas on how to fix this?

Alex

Answer: 
The basic approach I would recommend is to have a unique id for each form, and then subscribe to the `form.valueChanges`, possibly with a debounce to not write on every keystroke, and then write to localStorage in the subscribe block. Or delegate to a service to do so (that way, you can change the persistence mechanism later if desired).

Then on init of your form, use something like `form.setValue(valObj)` with the retrieved value from the service for that id.
structures that include circular references can't be serialized with JSON.stringify.use json-stringify-safe instead

<https://github.com/isaacs/json-stringify-safe>

it doesn't throw on circular references.