Skip to content

Commit ee88c52

Browse files
authored
Update README.md
1 parent 7a7d558 commit ee88c52

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Diff for: README.md

+3
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ If you need local-only environment variables that you don't place in `netlify.to
135135
If you are new to writing Lambda functions, this section may help you. Function signatures should conform to one of either two styles. Traditional callback style:
136136

137137
```js
138+
// legacy callback style - not encouraged anymore, but you'll still see examples doing this
138139
exports.handler = function(event, context, callback) {
139140
// your server-side functionality
140141
callback(null, {
@@ -149,13 +150,15 @@ exports.handler = function(event, context, callback) {
149150
or you can use async/await:
150151

151152
```js
153+
// modern JS style - encouraged
152154
export async function handler(event, context) {
153155
return {
154156
statusCode: 200,
155157
body: JSON.stringify({ message: `Hello world ${Math.floor(Math.random() * 10)}` })
156158
};
157159
}
158160
```
161+
> :warning: The above example only works with `netlify-lambda` because [it uses ES module syntax](https://community.netlify.com/t/async-await-lambda-function-example/6976/3)! If you get `Function invocation failed: SyntaxError: Unexpected token 'export'.` errors, this is why.
159162
160163
For more Functions examples, check:
161164

0 commit comments

Comments
 (0)