Need webhook function data inside loop()


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  

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.