diff --git a/libs/wingsdk/src/shared-gcp/function.inflight.ts b/libs/wingsdk/src/shared-gcp/function.inflight.ts index 99ca9085f4f..e3dda783b93 100644 --- a/libs/wingsdk/src/shared-gcp/function.inflight.ts +++ b/libs/wingsdk/src/shared-gcp/function.inflight.ts @@ -30,7 +30,7 @@ export class FunctionClient implements IFunctionClient { if (!res.ok) { throw new Error(res.body); } - return res.body ?? ""; + return res.body; } catch (error) { throw new Error( `Error while invoking the function ${this.functionName}:\n${ @@ -65,7 +65,7 @@ export class FunctionClient implements IFunctionClient { }, }, }); - return res.data as string | undefined; + return (res.data as string) || undefined; } catch (error) { throw new Error( `Error while invoking the function ${this.functionName}:\n${ diff --git a/libs/wingsdk/src/target-tf-gcp/function.ts b/libs/wingsdk/src/target-tf-gcp/function.ts index ac1ef1f1d5e..fd644a1f0de 100644 --- a/libs/wingsdk/src/target-tf-gcp/function.ts +++ b/libs/wingsdk/src/target-tf-gcp/function.ts @@ -208,9 +208,8 @@ export class Function extends cloud.Function { lines.push(" res.set('Access-Control-Allow-Methods', 'GET, POST')"); lines.push(" try {"); - lines.push( - ` const result = await (${inflightClient}).handle(req.body ?? "")` - ); + lines.push(` + const result = await (${inflightClient}).handle(req.body || undefined)`); lines.push(` res.send(result);`); lines.push(` } catch (error) {`); lines.push(` res.status(500).send(error.message);`);