Skip to content

Commit

Permalink
invokeOptions is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
inian committed Mar 23, 2022
1 parent a702f70 commit a3ef64d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ export class FunctionsClient {
*/
async invoke(
functionName: string,
invokeOptions: FunctionInvokeOptions
invokeOptions?: FunctionInvokeOptions
): Promise<{ data: string | null; error: Error | null }> {
try {
const { headers, body } = invokeOptions
const { headers, body } = invokeOptions ?? {}
const response = await this.fetch(`${this.url}/${functionName}`, {
method: 'POST',
headers: Object.assign({}, this.headers, headers),
body,
})

let data
const { responseType } = invokeOptions
const { responseType } = invokeOptions ?? {}
if (!responseType || responseType === 'json') {
data = await response.json()
} else if (responseType === 'arraybuffer') {
Expand Down

0 comments on commit a3ef64d

Please sign in to comment.