How to chain axios HTTP requests

I have 2 async await functions – one of them makes axios post request and another one – axios get request.

How could I chain them so that I would wait until the post operation is done and after it is completed, fetch new and updated objects?

const expensesListToDB = async () => {
    await axios.post('http://localhost:4000/app/expenseslist', 
    {
        expenseTitle: Expense,
        expenseAmount: Amount
    });
}

const expensesListFromDB = async () => {
    await axios.get('http://localhost:4000/app/expenseslist')
    .then(
    response => setExpenseAndAmountList(response.data && response.data.length > 0 ? response.data : []));
}

expensesListToDB();
expensesListFromDB();

Thanks!

Answer

you can put expensesListFromDB() in the ‘then’ method of the Axios.

const expensesListToDB = async () => {
    await axios.post('http://localhost:4000/app/expenseslist', 
    {
        expenseTitle: Expense,
        expenseAmount: Amount
    }).then(
    response => expensesListFromDB()); }

const expensesListFromDB = async () => {
    await axios.get('http://localhost:4000/app/expenseslist')
    .then(
    response => setExpenseAndAmountList(response.data && response.data.length > 0 ? response.data : [])); }

expensesListToDB();