0

I have a cloud code written

Parse.Cloud.define("getApartmentVendorProduct", function(request, response) {
  var isApartmentCallComplete = false;
  var isVendorCallComplete = false;
  var isProductCallComplete = false;

  var result = {};

  var apartmentQuery = new Parse.Query("Apartment");
  apartmentQuery.find({
    success: function(results) {
      isApartmentCallComplete = true;
      results.apartments = results;
    }
  });

  var vendorQuery = new Parse.Query("Vendor");
  vendorQuery.find({
    success: function(results) {
      isVendorCallComplete = true;
      results.vendors = results;
    }
  });

  var productQuery = new Parse.Query("Product");
  productQuery.find({
    success: function(results) {
      isProductCallComplete = true;
      results.products = results;
    }
  });

  setInterval(function () {
    if (isApartmentCallComplete && isVendorCallComplete && isProductCallComplete) {
      response.success(results);
    }
  }, 50);

});

PS: I'm well aware that setInterval wont work on Parse.. This code is just for understanding.

In this cloud function i'm making 3 Query operation.

From my Android application i'm calling this cloud code.

Here is my question. How many API request is this considered?

1) 3 API Request made by cloud code and 1 API Request made by Android - Total 4

2) Just 1 API Request made by Android. - Total 1

Kavin Varnan
  • 1,989
  • 18
  • 23

1 Answers1

0

The option is 1 it makes 4 requests.

I tried with a sample code to test Burst Limit

Parse.Cloud.define("testBurstLimit", function(request, response) {
  var globalI = 0;
  for(var i = 0; i < 500; i++) {
    var productQuery = new Parse.Query("Product");
    productQuery.find({
      success: function(results) {
        console.log("success " + i  + " " + globalI);
        globalI++;
        if (globalI == 250) {
          response.success("success");
        }
      },
      error: function(error) {
        isApartmentCallComplete = true;
        if (isApartmentCallComplete && isVendorCallComplete && isProductCallComplete) {
          console.log(error.message + " " + error.code);
        }
      }
    });
  }
});

One thing strange i noticed is that. Parse doesn't calculate requests/second, instead it calculates in Requests per/min. Check the response from Parse when i perform the BurstLimit cloud code again and again

{"code":155,"error":"This application performed 1814 requests over the last 28s, and exceeded its request limit. Please retry in 32s"}
Kavin Varnan
  • 1,989
  • 18
  • 23