Insert into collection then send email notification

In my application I’m using reactjs

I have onSubmit function that executes the email notification and I have another that inserts the form data into a collection in the database.

I want to have the data inserted into the database and then send out an email notification.

I’m having some trouble getting the 2 onSubmit functions to work together ?