Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import { ProductService } from '../lib/product-service.js'
import { client, headers } from '../lib/config.js'
const service = new ProductService({ client })
exports.handler = async (event, context) => {
console.log('Function `products` invoked')
if (event.httpMethod !== 'GET') {
return { statusCode: 405, headers, body: 'Method Not Allowed' }
}
try {
const products = await service.getProducts()
return {
statusCode: 200,
headers,
body: JSON.stringify(products),
}
} catch (error) {
console.log('error', error)
return {
statusCode: 400,
headers,
body: JSON.stringify(error),
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.