Skip to content

Instantly share code, notes, and snippets.

@tataihono
Created February 25, 2022 01:31
Show Gist options
  • Save tataihono/10c1244e30226fbe941a33f04cd099bb to your computer and use it in GitHub Desktop.
Save tataihono/10c1244e30226fbe941a33f04cd099bb to your computer and use it in GitHub Desktop.
const findAccountNumber = () => {
const accountNumber = `EV${_.padStart(_.random(1000000, 999999), 6, '0')}`;
return $fluro.api
.post("/content/financialDetail/filter", {
filter: {
operator: "and",
filters: [
{
operator: "and",
filters: [
{
comparator: "==",
key: "data.accountNumber",
value: accountNumber,
},
],
},
],
},
})
.then((res) => {
if (res.data.length === 0) {
return setAccountNumber(accountNumber);
} else {
return findAccountNumber();
}
})
.catch(done);
};
return findAccountNumber();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment