MCPcopy Create free account
hub / github.com/firebase/firebase-tools / requestCallBack

Method requestCallBack

src/localFunction.ts:220–241  ·  view source on GitHub ↗
(err: unknown, response?: ClientResponse<T>, body?: string | object)

Source from the content-addressed store, hash-verified

218 }
219
220 private requestCallBack<T>(err: unknown, response?: ClientResponse<T>, body?: string | object) {
221 if (err) {
222 return console.warn("\nERROR SENDING REQUEST: " + err);
223 }
224 const status = response ? response.status + ", " : "";
225
226 // If the body is a string we want to check if we can parse it as JSON
227 // and pretty-print it. We can't blindly stringify because stringifying
228 // a string results in some ugly escaping.
229 let bodyString = body;
230 if (typeof bodyString === "string") {
231 try {
232 bodyString = JSON.stringify(JSON.parse(bodyString), null, 2);
233 } catch (e) {
234 // Ignore
235 }
236 } else {
237 bodyString = JSON.stringify(body, null, 2);
238 }
239
240 return console.log("\nRESPONSE RECEIVED FROM FUNCTION: " + status + bodyString);
241 }
242
243 private isDatabaseFn(eventTrigger: Required<EmulatedTriggerDefinition>["eventTrigger"]) {
244 return utils.getFunctionsEventProvider(eventTrigger.eventType) === "Database";

Callers 2

constructCallableFuncMethod · 0.95
verbFactoryMethod · 0.95

Calls 2

parseMethod · 0.80
logMethod · 0.45

Tested by

no test coverage detected