Created
February 25, 2022 01:31
-
-
Save tataihono/10c1244e30226fbe941a33f04cd099bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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