Jonah in his prayer to Yahweh tried to justify his former actions. He claimed that Yahweh was so gracious and merciful that he would not have inflicted any damage on Nineveh. Jonah gave that as his reason for originally trying to flee to Tarshish. He knew that Yahweh was slow to anger and abounding with steadfast love. Thus, he knew that Yahweh was eager and ready to not punish the people of Nineveh.
This is one of the few cases where God changing his mind. God did not bring destruction to Nineveh. God saw how the people and the leaders of Nineveh had turned from their evil ways. Thus, he decided not to bring destruction to this non-Israelite town, because of their repentance. God showed mercy to them.