add netlify function
This commit is contained in:
parent
db2c9bcd36
commit
bb8accf537
2 changed files with 20 additions and 0 deletions
17
functions/random-names/random-names.js
Executable file
17
functions/random-names/random-names.js
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
// Docs on event and context https://www.netlify.com/docs/functions/#the-handler-method
|
||||||
|
const handler = async (event) => {
|
||||||
|
try {
|
||||||
|
const subject = event.queryStringParameters.name || 'World'
|
||||||
|
return {
|
||||||
|
statusCode: 200,
|
||||||
|
body: JSON.stringify({ message: `Hello ${subject}` }),
|
||||||
|
// // more keys you can return:
|
||||||
|
// headers: { "headerName": "headerValue", ... },
|
||||||
|
// isBase64Encoded: true,
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
return { statusCode: 500, body: error.toString() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { handler }
|
3
netlify.toml
Normal file
3
netlify.toml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[build]
|
||||||
|
publish = "dist"
|
||||||
|
functions = "functions"
|
Loading…
Add table
Reference in a new issue