This has to be done gently and patiently. Let them know why you acted hastily, along with giving reasons for you why you regret it now. You should explain that the divorce is not a solution but a mistake. Tell them you spoke out of anger or were agitated. Accepting a mistake now is much better than repenting for the years to come.
It can be a difficult step, but it is indeed necessary. The fact that you brought up the issue of divorce, will make you responsible for the entire ordeal. Sometimes, the spouse agrees to the idea out of anger and retaliation. If they said yes, but you still love them its time to stop the divorce.
Get to know whether your spouse actually wants the divorce or not. If they agree out of anger, you both will be miserable for the rest of your lives. This is a decision that requires a lot of time and reason. Only then one can decide if they were right about a divorce. The step to save your marriage should not be late.
Try and be very mature and calm through out this ordeal. It will not be very easy to do. Since divorce is a very emotional ordeal it can lead to a lot of pain. However, if you are planning to stay married, be patient. Getting into squabbles and yelling wont help. Screaming and accusing or pointing fingers at each other will make things worse. You should vent out the anger and resentment towards your partner. Start with an apology and then work out things.
Have the will to work on your problems. Agree to the fact that no relationship can go back to the way it was. Changes will be done for the better. I hope now you got the answer for the question “how to prevent a divorce?“.