razorpay / razorpay/razorpay-node

[Feature Request] API to fetch all customers at once

Open
#307 1 comment 0 reactions 1 assignee View on GitHub

@ankitdas13 is already working on this.

Since Dec 5, 2022.

enhancement
Dominant language
JavaScript
Stars
243
Forks
128
PR merge metrics
No merged PRs in 30d

Description

I didn't find any API which can fetch customer's data at once so please add the feature.

The existing feature of getting all customers limit the customer's data to 100 max. So in order to get the data we need to use a loop and use skip.

To bypass this here is a temporary solution to get all customer's data at once

Function:-

async function getCustomers(){
	let customerData = [];
	let skip = 0;

	while(true){
		const response = await razorpay.customers.all({count: 100, skip: skip})
		count = response.count;

		for(let item in response.items){
			customerData.push(response.items[item]);
		};

		if(count < 100){ break; } else{ skip +=100 }
	}
	return customerData
}

Usage:-

getCustomers().then((data)=>{
	// Total Customer Count
	console.log(data.length);

	// Total Customer Data in an Array
	// console.log(data)
})

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.