Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.

Commit 5fa6c5a

Browse files
committed
Expose netlifyFunction params as netlifyFunctionParams
Expose event and context of Netlify Function in Next.js pages and API routes as `netlifyFunctionParams` (rather than `netlifyFunction`). The new name is clearer, since we're just making the parameters of the function available and not the function itself.
1 parent 1ba11f8 commit 5fa6c5a

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ const Page = () => <p>Hello World!</p>;
212212
export const getServerSideProps = async ({ req }) => {
213213
// Get event and context from Netlify Function
214214
const {
215-
netlifyFunction: { event, context },
215+
netlifyFunctionParams: { event, context },
216216
} = req;
217217

218218
// Access Netlify identity
@@ -232,7 +232,7 @@ To access Netlify Identity from pages without server-side rendering, you can cre
232232
export default async function getUser(req, res) {
233233
// Get event and context from Netlify Function
234234
const {
235-
netlifyFunction: { event, context },
235+
netlifyFunctionParams: { event, context },
236236
} = req;
237237

238238
// Access Netlify identity

cypress/fixtures/pages/getServerSideProps/wait-on-empty-event-loop/[wait].js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const getServerSideProps = async ({ params, req }) => {
66

77
// Set behavior of whether to wait for empty event loop
88
const wait = String(params.wait).toLowerCase() === "true";
9-
const { context: functionContext } = req.netlifyFunction;
9+
const { context: functionContext } = req.netlifyFunctionParams;
1010
functionContext.callbackWaitsForEmptyEventLoop = wait;
1111

1212
return {

cypress/integration/default_spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ describe("getServerSideProps", () => {
144144
.then((json) => {
145145
const {
146146
req: {
147-
netlifyFunction: { event, context },
147+
netlifyFunctionParams: { event, context },
148148
},
149149
} = JSON.parse(json.html());
150150

@@ -582,7 +582,7 @@ describe("API endpoint", () => {
582582
cy.request("/api/context").then((response) => {
583583
const {
584584
req: {
585-
netlifyFunction: { event, context },
585+
netlifyFunctionParams: { event, context },
586586
},
587587
} = response.body;
588588

lib/templates/createRequestObject.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const createRequestObject = ({ event, context }) => {
5858
// It also allows users to change the behavior of waiting for empty event
5959
// loop.
6060
// See: https://github.com/netlify/next-on-netlify/issues/66#issuecomment-719988804
61-
req.netlifyFunction = { event, context };
61+
req.netlifyFunctionParams = { event, context };
6262

6363
for (const key of Object.keys(multiValueHeaders)) {
6464
for (const value of multiValueHeaders[key]) {

0 commit comments

Comments
 (0)