Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.handler = function(event, _context, callback) {
const pipedrive = new Pipedrive.Client(process.env.PIPEDRIVE_KEY, {
strictMode: true,
});
// onlt allow post method
if (event.httpMethod !== 'POST') {
return callback(null, { statusCode: 403 });
}
const formData = JSON.parse(event.body);
const { name, email, phone, website, comments } = formData;
// check for required fields
if (!name || !email) {
return callback(null, { statusCode: 400 });
}
const names = name.split(' ');
// eslint-disable-next-line prefer-const