# Update data in module.exports by function

**URL:** <https://forums.fusetools.com/t/update-data-in-module-exports-by-function/3161>\
**Category:** How-to Discussions\
**Created:** [March 14, 2017, 4:53pm UTC](https://forums.fusetools.com/t/update-data-in-module-exports-by-function/3161 "2017-03-14T16:53:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bulakhvad](https://avatars.discourse-cdn.com/v4/letter/b/3d9bf3/32.png) [@bulakhvad](https://forums.fusetools.com/u/bulakhvad)\
**Post date:** [March 14, 2017, 4:53pm UTC](https://forums.fusetools.com/t/update-data-in-module-exports-by-function/3161/1 "2017-03-14T16:53:00Z")

</div>

I have this JS code, and my functions change variable ‘index’, but not in module.exports. How can i fix it?

```javascript
var Observable = require("FuseJS/Observable");
	var Bundle = require("FuseJS/Bundle");
	var stages = Observable();
	stages = JSON.parse(Bundle.readSync("stages.json"));
	var index = stages.nTag;

	console.log(JSON.stringify(stages.Stage1[index]));

	function onVar1(context) {
		index = stages.Stage1[index].Var1.tag;

	}
	function onVar2(context) {
		index = stages.Stage1[index].Var2.tag;
	}
	module.exports = {
		stages: stages.Stage1[index],
		onVar1: onVar1,
		onVar2: onVar2
	};

```

---

<div class="post-metadata">

**Author:** ![bulakhvad](https://avatars.discourse-cdn.com/v4/letter/b/3d9bf3/32.png) [@bulakhvad](https://forums.fusetools.com/u/bulakhvad)\
**Post date:** [March 15, 2017, 8:10pm UTC](https://forums.fusetools.com/t/update-data-in-module-exports-by-function/3161/2 "2017-03-15T20:10:33Z")

</div>

I did not understand the philosophy of working with Observable 😃  
This code working fine

```javascript
	var Observable = require("FuseJS/Observable");
	var Bundle = require("FuseJS/Bundle");
	//
	var stages = JSON.parse(Bundle.readSync("stages.json"));
	var index = stages.nTag; 
	var st = Observable(stages.Stage1[index]); //new var for exports
	function onVar1(context) {
		index = stages.Stage1[index].Var1.tag;
		st.value = stages.Stage1[index]; //change value in exports
	}
	function onVar2(context) {
		index = stages.Stage1[index].Var2.tag;
		st.value = stages.Stage1[index]; //there too
	}
	module.exports = {
		nstages: st,
		onVar1: onVar1,
		onVar2: onVar2
	};

```
