# Need webhook function data inside loop()

**URL:** <https://community.particle.io/t/need-webhook-function-data-inside-loop/41659>\
**Category:** Troubleshooting\
**Created:** [May 4, 2018, 10:03pm UTC](https://community.particle.io/t/need-webhook-function-data-inside-loop/41659 "2018-05-04T22:03:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![orionlogic](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/orionlogic/32/17329_2.png) [@orionlogic](https://community.particle.io/u/orionlogic)\
**Post date:** [May 4, 2018, 10:03pm UTC](https://community.particle.io/t/need-webhook-function-data-inside-loop/41659/1 "2018-05-04T22:03:50Z")

</div>

Hi,

I can successfully get webhook data with handler, but i want that data inside loop() not in handler function.

How can i get the data(_priceData_ in code) to use it inside loop?

```
void setup() {
    Particle.subscribe("hook-response/price", priceData, MY_DEVICES);
}

void loop() {      
  String data = String(10);
  // Trigger the integration
  bool success = Particle.publish("triggerPrice", data, PRIVATE);
     
}

void priceData(const char *event, const char *data) {       
  int price = atof(data);
//price is 2500  
 
}
```

---

<div class="post-metadata">

**Author:** ![Ric](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ric/32/514_2.png) [@Ric](https://community.particle.io/u/Ric)\
**Post date:** [May 5, 2018, 12:33am UTC](https://community.particle.io/t/need-webhook-function-data-inside-loop/41659/2 "2018-05-05T00:33:24Z")

</div>

You only need to make price a global variable, so you can use it anywhere in your code. Don’t forget to remove the “int” in front of price in the priceData function. Also, be sure to have enough delay in loop to ensure you don’t publish more than once per second.
