# If statement For Extracting a specific data

**URL:** <https://discourse.nodered.org/t/if-statement-for-extracting-a-specific-data/33405>\
**Category:** General\
**Created:** [27 September 2020 12:21 UTC](https://discourse.nodered.org/t/if-statement-for-extracting-a-specific-data/33405 "2020-09-27T12:21:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amir](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@Amir](https://discourse.nodered.org/u/Amir)\
**Post date:** [27 September 2020 12:21 UTC](https://discourse.nodered.org/t/if-statement-for-extracting-a-specific-data/33405/1 "2020-09-27T12:21:22Z")

</div>

Good morning everyone....

The packet that is sent from the sensor is received by more than one Gateway.... I only need to extract the data from a specific gateway, the way I wrote the code doesn't work, What could be the right way?

The Function node Code:  
`msg.topic = "Data"`  
` var gateways = msg.metadata.gateways;`  
` `  
` msg.payload = {`  
` gateways: gateways.map(gw => {`  
` if(gateways.gtw_id == "eui-60c5a8fffe7664c3")`  
` return {`  
` Counter: msg.counter,`  
` Node_Time : String(msg.payload),`  
` GwTime : gateways.map(gw => gw.time).slice(11,23) ,`  
` Air_Time : String(msg.metadata.airtime).slice(0,7),`  
` TTN_Time: msg.metadata.time.slice(11,23),`  
` DataRate: msg.metadata.data_rate,`  
` }`  
` }) `  
` }`  
`return msg`

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/a/8ac220e5ce9334434abcb456b63ab74cebd8fff9.png)

It would be nice if someone tells me the difference between using this statement

GwTime = gateways.map(gw =\> gw.time).slice(11,23) ;

And this statement

GwTime: gateways.map(gw =\> gw.time).slice(11,23),

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [26 November 2020 12:21 UTC](https://discourse.nodered.org/t/if-statement-for-extracting-a-specific-data/33405/2 "2020-11-26T12:21:23Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
