titi23 titi23 - 6 months ago 17
Javascript Question

How to check status of the user (subscribed or not) using sendy

I am using sendy-api, to do subscribe for user from the code. I am using javascript. Also I have followed sendy-github .

I want to check the status of the user before doing subscribe. If user is unsubscribed already, I dont want to subscribe again. Giving the code that I have tried.



var Sendy = require('sendy-api'),
sendy = new Sendy('http://your_sendy_installation'),

sendyStatus = new Sendy('http://your_sendy_installation/api/subscribers/subscription-status.php'); //There is something wrong in this part I think

var eachUser = {em : 'abcd@xyz.com'};

sendyStatus.status({email: eachUser.em, list_id: 'someListID'}, function(err, userInfo)
{
console.log(userInfo)
});





Getting the error as below:-

Error in getting user status from sendy{ [Error: [404 error] If you're seeing this error after install, check this FAQ for the fix: https://sendy.co/troubleshooting#404-error]
[message]: '[404 error] If you\'re seeing this error after install, check this FAQ for the fix: https://sendy.co/troubleshooting#404-error' } at [Tue May 10 2016 12:55:30 GMT+0530 (IST)]
jobScheduler:error: performJob failed{ [Error: [404 error] If you're seeing this error after install, check this FAQ for the fix: https://sendy.co/troubleshooting#404-error]
[message]: '[404 error] If you\'re seeing this error after install, check this FAQ for the fix: https://sendy.co/troubleshooting#404-error' } at [Tue May 10 2016 12:55:30 GMT+0530 (IST)]

Any body has any idea how to solve the issue? Anything wrong I am doing?

Answer

I forgot to add 'api-key' so I was getting the error, as it is written in github.

Now the code is as below and it is working :-

var Sendy = require('sendy-api'),
    sendy = new Sendy('http://your_sendy_installation', 'api-key'); // Without api key it won't work.
   

var eachUser = {em : 'abcd@xyz.com'};

 sendy.status({email: eachUser.em, list_id: 'someListID'}, function(err, userInfo)                       
   {
      console.log(userInfo) // will give status of the user.
   });

Comments