How to properly send Triggered emails?

I’m trying to use triggered emails with my custom form and attached the code snippet of the triggered email to the onClick event of my submit button.

Here’s the code:

export function submitBtn_click(event) {
      $w('#dataset1').setFieldValue('clientName', $w('#IDField').value)
    $w('#dataset1').setFieldValue('status', "Submitted")
    $w('#dataset1').setFieldValue('submittedBy', creator)
    console.log("This is the ID of the selected user: "+ $w('#IDField').value);  
    triggeredEmails.emailMember('SosUI4m', $w('#IDField').value, {
    variables: {
    name: $w('#clientField').value

It displays the correct _id of the selected user. However, I get this error in the console results: