Hello Community,

i have exactly the same issue.
I have written a function, in which I use the query parameters and the response as described in: Custom Endpoint Documentation and shown in the Example

Endpoint-Function:

exports = async function(request, response){
  
  // -------------------------------------- GENERATE COLLECTION --------------------------------------
  const SERVICE_NAME = "EXAMPLE";
  const DATABASE_NAME = "EXAMPLE";
  const COLLECTION_NAME = "EXAMPLE";

  collection = context.services.get(SERVICE_NAME).db(DATABASE_NAME).collection(COLLECTION_NAME);


  // -------------------------------------- EXTRACT REQUEST PARAMETERS ------------------------------------
  const queryParams = request.query;

  var brand;
  var paramName = "Brand"
  if (queryParams && queryParams.hasOwnProperty(paramName)) {
    brand = queryParams[paramName];
    console.log(`Parameter "${paramName}" found: ${brand}`);
  } else {
    console.log(`Parameter "${paramName}" is missing in query`);
    response.setStatusCode(400);
  }

  var models;
  try {
    models = await collection.distinct("vehicle_model.model",{'vehicle_model.make': brand});
  } catch(err) {
    console.log("Error occurred while executing:", err.message);
    response.setStatusCode(500);
    return { error: err.message };
  }

  return { models: models };
};

I get the same error as @Sai_kiran2 :

{"message":"Cannot access member 'setStatusCode' of undefined","name":"TypeError"}