I am not getting the list of subscriptions that I expected based on the Paddle list subscriptions documentation.
Here, there is no required field for query parameters, so if I send {}, then it should return whole list of subscriptions.
Below is my code for getting the list of subscriptions. I had used the Paddle SDK, and created a Paddle Provider. For the particular user's subscription, I passed the customerId also, but it still does not return any data.
const getUserAllSubscription = async (req, res) => {
try {
const userSubscriptions = paddle.subscriptions.list({
customerId: 'ctm_xxxxxxxxxxxxxxx',
});
console.log("userSubscriptions >>>>>>", userSubscriptions);
return res.status(200).send(userSubscriptions);
} catch (error) {
console.error(`Error from PADDLE > getUserAllSubscription: ${error}`, 'error');
throw error;
}
}
Below is the response that I am getting:
userSubscriptions >>>>>> SubscriptionCollection {
client: Client {
apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
options: { environment: 'sandbox', logLevel: 'verbose' },
baseUrl: 'https://sandbox-api.paddle.com'
},
hasMore: true,
estimatedTotal: 0,
data: [],
nextLink: '/subscriptions?customer_id=ctm_xxxxxxxxxxxxxxx'
}
const list = paddle.subscriptions.list();
const result = [];
for await (const item of list) {
result.push(item);
}
The returned list is not a regular array but an iterable object. Try iterating over it and see what happens.