Skip to content

Instantly share code, notes, and snippets.

@imrhlrvndrn
Last active December 28, 2019 11:36
Show Gist options
  • Save imrhlrvndrn/3dfd0557e1373591aa2337f078f99371 to your computer and use it in GitHub Desktop.
Save imrhlrvndrn/3dfd0557e1373591aa2337f078f99371 to your computer and use it in GitHub Desktop.
The first axios post request creates a new expense in the expenses collection and the second axios request in the .then() updates the current balance of the logged user. In the production app the expense is created but the second axios request is not executed and hence the current balance of the user is not updated. Please suggest something to o…
axios
.post("/expense/add", newExpense)
.then(() => {
if (expenseList[0].whatfor === "recharge") {
const updateInfo = {
username: userInfo.username,
email: userInfo.email,
password: userInfo.password,
income: Number(userInfo.income),
expense: Number(userInfo.expense),
curbal: Number(userInfo.curbal) + Number(newExpense.totalPrice)
};
axios
.post("/user/update", updateInfo)
.then(() => window.location.assign("/"))
.catch(err => console.log(err));
}
)
.catch(err => console.error(err));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment