starsy/functions/random-names/random-names.js

18 lines
553 B
JavaScript
Raw Normal View History

2022-01-22 15:58:03 +01:00
// 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,
2022-01-22 16:18:57 +01:00
body: JSON.stringify({ message: `Hello ${subject}`, path: event.path }),
2022-01-22 15:58:03 +01:00
// // more keys you can return:
// headers: { "headerName": "headerValue", ... },
// isBase64Encoded: true,
}
} catch (error) {
return { statusCode: 500, body: error.toString() }
}
}
module.exports = { handler }