| 37 | } |
| 38 | |
| 39 | private constructCallableFunc(data: string | object, opts: { instanceIdToken?: string }): void { |
| 40 | opts = opts || {}; |
| 41 | |
| 42 | const headers: Record<string, string> = {}; |
| 43 | if (opts.instanceIdToken) { |
| 44 | headers["Firebase-Instance-ID-Token"] = opts.instanceIdToken; |
| 45 | } |
| 46 | |
| 47 | if (!this.url) { |
| 48 | throw new Error("No URL provided"); |
| 49 | } |
| 50 | |
| 51 | const client = new Client({ urlPrefix: this.url, auth: false }); |
| 52 | void client |
| 53 | .post<any, any>("", data, { headers }) |
| 54 | .then((res) => { |
| 55 | this.requestCallBack<any>(undefined, res, res.body); |
| 56 | }) |
| 57 | .catch((err) => { |
| 58 | this.requestCallBack(err); |
| 59 | }); |
| 60 | } |
| 61 | |
| 62 | private constructHttpsFunc(): requestShim { |
| 63 | if (!this.url) { |