# TagoCore (TAGOCORE\_DATA)

**URL:** <https://community.tago.io/t/tagocore-tagocore-data/1250>\
**Category:** Support\
**Created:** [September 30, 2022, 7:50pm UTC](https://community.tago.io/t/tagocore-tagocore-data/1250 "2022-09-30T19:50:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![drcanalli](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@drcanalli](https://community.tago.io/u/drcanalli)\
**Post date:** [September 30, 2022, 7:50pm UTC](https://community.tago.io/t/tagocore-tagocore-data/1250/1 "2022-09-30T19:50:27Z")

</div>

I have Tagocore installed and running inside a Raspberry pi3.  
The Integration with Tago-IO is running smoothly.  
I need to work with the data inside Tagocore and for that I’m using a script invoked by the “Action” function, and this “Action” is also working.  
At the moment I use the following support to access tagocore data through the script ([https://tagocore.com/docs/analysis/code)](https://tagocore.com/docs/analysis/code)) This document points in its script an example of accessing the TAGOCORE\_DATA environment.  
My data array follows the proper model suggested by Tagocore/Tago-IO.  
---------------------------------------------------------------------------------------------------------  
PROBLEM: Executing the script returns an error in the Analysis console.  
---------------------------------------------------------------------------------------------------------  
This is the Scope data which is being sent by the device, the token of this device was place in the environment variable of Analysis  
----------------------------------------------------------------------------------------------------------

[

```
{

    "variable": "temperature",

    "value": 16.5

},

{

    "variable": "humidity",

    "value": 74

}

```

]

----------------------------------------------------------------------------------------------------------  
This is the suggested script:  
----------------------------------------------------------------------------------------------------------

const data = process.env.TAGOCORE\_DATA;

const temperatureItem = data.find((i) =\> i.variable === ‘temperature’);

console.log(“Temperature is at:”, temperatureItem.value);

---------------------------------------------------------------------------------------------------------

The error returned is:

---------------------------------------------------------------------------------------------------------

[2022-09-30 16:27:01.564]: Finishing script execution with code 1

[2022-09-30 16:27:01.552]: /home/pi/Users/tagocore/project-code/calculo\_01\_edit1.js:2

const temperatureItem = data.find((i) =\> i.variable === ‘temperature’);

```
                         ^

```

TypeError: Cannot read property ‘find’ of undefined

```
at Object.<anonymous> (/home/pi/Users/tagocore/project-code/calculo\_01\_edit1.js:2:30)

at Module.\_compile (internal/modules/cjs/loader.js:1085:14)

at Object.Module.\_extensions..js (internal/modules/cjs/loader.js:1114:10)

at Module.load (internal/modules/cjs/loader.js:950:32)

at Function.Module.\_load (internal/modules/cjs/loader.js:790:14)

at Function.executeUserEntryPoint \[as runMain\] (internal/modules/run\_main.js:76:12)

at internal/main/run\_main\_module.js:17:47

```

[2022-09-30 16:27:01.062]: Starting analysis 6140e438ed59eb1f99dc68f0  
---------------------------------------------------------------------------------------------------------------------------------------

Finally:

.

If I run the script separately elsewhere without the line (const data = process.env.TAGOCORE\_DATA;) it works correctly and returns the following: (“Temperature is at:” 16.5)  
--------------------------------------------------------------------------------------------------------------------------------------

I would really appreciate your help from the community.

---

<div class="post-metadata">

**Author:** ![benachio](https://avatars.discourse-cdn.com/v4/letter/b/ecae2f/32.png) [@benachio](https://community.tago.io/u/benachio)\
**Post date:** [October 5, 2022, 5:08pm UTC](https://community.tago.io/t/tagocore-tagocore-data/1250/2 "2022-10-05T17:08:13Z")

</div>

Hey @drcanalli

It seems like our documentation is outdated in this section, the correct example would be this one:

----------------------------------------------------------------------------------------------------------

const { Analysis } = require(“@tago-io/sdk”);

// The function myAnalysis will run when you execute your analysis

function myAnalysis(context, scope) {

// This will log the scope to the TagoIO Analysis console  
// You can do anything you want with it

context.log(“my scope:”, scope);

}

module.exports = new Analysis(myAnalysis);

----------------------------------------------------------------------------------------------------------

Make sure you have the package @tago-io/sdk installed in your project.

I’ll make sure to update our documentation, and I hope this solves your issue!

---

<div class="post-metadata">

**Author:** ![drcanalli](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@drcanalli](https://community.tago.io/u/drcanalli)\
**Post date:** [October 7, 2022, 12:35pm UTC](https://community.tago.io/t/tagocore-tagocore-data/1250/3 "2022-10-07T12:35:30Z")

</div>

Perfect Matt!

.

Yes, the problem was solved with your help.

Analysis running normally.

Thanks for the support.
