Search code examples
javascriptnode.jsapisendy

How to pass custom parameters to sendy via node js api?


I am trying to pass custom data in sendy via api of sendy. Sendy has custom field attributes in which we can pass data. I am using a sendy node js package whose link is provided on sendy website. the issue is that i am not able to pass custom field data to sendy api. Here is my code

 var params = {
            email: email2,
            custom: {
                'assignmentDetail':assignmentLink,
                'submissionDetail':submissionDetail,
                'FormLink':reviewerFormLink,
            },
            list_id: ListID,
            api_key: 'vQzxtX76pNFekG4w5BzC'
        };
        sendy.subscribe(params, function (err, result) {  if (err){ 
                console.log(err.toString());
                }else{ 
                UpdateData(recordID, email2, ListID);     
                console.log('Subscribed succesfully');}
            });

the custom field data is not being passed in the sendy. Please help


Solution

  • I have found the solution to my problem. It is very simple. You need to make your custom fields in enclosed in quotes and you are done. Just like this

     var params = {
                email: email2,
             //make sure custom field names are same otherwise sendy would igore the fields
                    'assignmentDetail':assignmentLink,
                    'submissionDetail':submissionDetail,
                    'FormLink':reviewerFormLink,
                
                list_id: ListID,
                api_key: 'vQzxtX76pNFekG4w5BzC'
            };
            sendy.subscribe(params, function (err, result) {  if (err){ 
                    console.log(err.toString());
                    }else{ 
                    UpdateData(recordID, email2, ListID);     
                    console.log('Subscribed succesfully');}
                });