Once the issue of Achan’s thievery is dealt with, God turns from his fierce anger and promises victory over Ai. He instructs Joshua to take the whole army into battle, which included setting up an ambush.
When the victory over Ai is secured, Joshua sets up an altar to God. The word of God is read to the people of Israel and they rededicate themselves to God. Serving and obeying God became more importance than success on the battlefield.
Centuries later Jesus offered these words,
“Seek the Kingdom of God above all else, and he will give you everything you need.” Matthew 6:33 NLT