If I understand Chaining correctly, I’m able to pass content from one Edge Function to another as per netlify.toml
How can I pass JSON in the same manner? I tried using context.json(value) but I don’t think context gets updated
For example:
netlify.tom
[[edge_functions]]
function = “edge-json-1”
path = “/*”
[[edge_functions]]
function = “edge-json-2”
path = “/*”
edge-json-1.js
export default async (request, context) => {
let edgeJson1 = { hello: "world" };
context.json(edgeJson1);
context.log("-> returning edgeJson1", edgeJson1);
return context.next();
};
edge-json-2.js
export default async (request, context) => {
let edgeJson2 = context.json();
context.log("<- receiving context", context);
context.log("<- receiving context.json() as edgeJson2", edgeJson2);
return context.next();
};
console log
[edge-json-1] -> returning edgeJson1 { hello: "world" }
[edge-json-2] <- receiving context {
cookies: {
delete: [Function: bound delete],
get: [Function: bound get],
set: [Function: bound set]
},
geo: {
city: "XXX",
country: { code: "XX", name: "XXX" },
subdivision: { code: "XX", name: "XXX" }
},
json: [Function: bound json],
log: [Function],
next: [Function: next],
rewrite: [Function: bound rewrite]
}
[edge-json-2] <- receiving context.json() as edgeJson2 Response {
body: null,
bodyUsed: false,
headers: Headers { "content-type": "application/json" },
ok: true,
redirected: false,
status: 200,
statusText: "",
url: ""
}
Any help would be greatly appreciated!