Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:10:98

Then has there not been a ˹single˺ city that believed so its faith benefited it except the people of Jonah? When they believed, We removed from them the punishment of disgrace in worldly life and gave them enjoyment for a time.  

If only there had been one town — meaning its inhabitants — that believed, before chastisement befell it, and profited by its belief — except for the people of Jonah: when they believed, after seeing a portent of the chastisement, for they did not wait ˹to believe˺ until it came to pass, We removed from upon them the chastisement of degradation in the life of this world and We gave them comfort for a while, until the conclusion of their terms ˹of life˺.
القرآن:١٠:٩٨

فَلَوْلَا كَانَتْ قَرْيَةٌ آمَنَتْ فَنَفَعَهَا إِيمَانُهَا إِلَّا قَوْمَ يُونُسَ لَمَّا آمَنُوا كَشَفْنَا عَنْهُمْ عَذَابَ الْخِزْيِ فِي الْحَيَاةِ الدُّنْيَا وَمَتَّعْنَاهُمْ إِلَىٰ حِينٍ  

{فلولا} فهلا {كانت قرية} أريد أهلها {آمنت} قبل نزول العذاب بها {فنفعها إيمانها إلا} لكن {قوم يونس لما آمنوا} عند رؤية أمارة العذاب ولم يؤخروا إلى حلوله {كشفنا عنهم عذاب الخزي في الحياة الدنيا ومتعناهم إلى حين} انقضاء آجالهم.

See similar narrations below:

Collected by Suyūṭī
suyuti:4-1640bʿAli > In al-Ḥadhar Lā Yarud al-Qaḍāʾ And Lakin al-Duʿāʾ Yarud al-Qaḍāʾ > Allāh
Request/Fix translation

  

السيوطي:٤-١٦٤٠b

"عن عَلِىٍّ قَالَ: إِنَّ الْحَذَرَ لَا يَرُدُّ القَضَاءَ، وَلَكِنَّ الدُّعَاءَ يَرُدُّ القَضَاءَ، قَالَ الله تَعالَى: {إِلَّا قَوْمَ يُونُسَ لَمَّا آمَنُوا كَشَفْنَا عَنْهُمْ عَذَابَ الْخِزْيِ فِي الْحَيَاةِ الدُّنْيَا وَمَتَّعْنَاهُمْ إِلَى حِينٍ} ".  

ابن أبى حاتم والآلكائى