gentle-planet-18535
10/30/2024, 2:33 PMgentle-planet-18535
10/30/2024, 8:52 PM502 The Lambda function returned invalid JSON: The JSON output must be an object type
.
Looks like the handlerRequest
from @growthbook/edge-lambda
returns null
I am using this snippet:
import { handleRequest } from "@growthbook/edge-lambda";
export async function handler(event, ctx, callback) {
// Manually build your environment:
const env = buildEnv();
// Specify additional edge endpoint information:
env.host = "<http://www.mysite.io|www.mysite.io>";
// Uncomment for ease of testing locally - returns response instead of using callback():
// env.returnResponse = true;
handleRequest(event, callback, env);
}
function buildEnv() {
// todo: define environment variables here
}
I just added my build env and set env.host.happy-autumn-40938
11/01/2024, 5:10 PMhandleRequest()
isn't supposed to return anything (unless you set env.returnResponse = true;
). Instead its mean to call in internal callback.gentle-planet-18535
11/02/2024, 4:52 PMnull
. Returning the promise solved this issuehappy-autumn-40938
11/03/2024, 4:54 AM