Skip to content

Instantly share code, notes, and snippets.

@metehansenol
Created November 12, 2019 22:12
Show Gist options
  • Save metehansenol/34c3d0ba1707b4fe767cb70bddf55f8b to your computer and use it in GitHub Desktop.
Save metehansenol/34c3d0ba1707b4fe767cb70bddf55f8b to your computer and use it in GitHub Desktop.
Getting Customer Account Balance
async componentDidUpdate(prevProps, prevState) {
const accountCode = this.props.accountCode;
if (accountCode !== prevProps.accountCode) {
let header = await Auth.header();
const data = await fetch(`${global.bpmApiUrl}/logo-tedarikciler?cariHesapKodu=${accountCode}`, {headers: header})
.then(response => response.json());
if (data.length > 0) {
let balance = 0;
let moneySign = data[0].moneySign;
data.forEach(item => balance += item.muhasebeBakiye);
this.setState({
balance,
moneySign
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment