This is my attempt:``` export async function crmSaveAction(context: Context) {const crmRepository = getManager().getRepository(CrmEntity);context.body = context.request.body; const { email } = context.body.email; const data = context.request.body;const contactToBeSaved = await crmRepository.findOne({ where: { email }, })console.log(>>> Body here: ${context.body}); console.log(>>> Email here: ${email}); console.log(>>> Params here: ${context.params});if (contactToBeSaved) { context.body = Email already registered! }const newContact = await crmRepository.create(context.request.body);await crmRepository.save(newContact);console.log(newContact);context.body = newContact;} ```In console:>>> Body here: [object Object]>>> Email here: undefined>>> Params here: [object Object]But it does nothing and duplicated emails are registered. Please help.Full code's here: https://ift.tt/2RrTtxi
Submitted October 31, 2018 at 04:59AM by xzenuu
No comments:
Post a Comment