My doctor said bananas and wear snug socks to bed.
I had it too. Drinking plenty of fluid, mainly water and milk helped me. I also had bananas and green coconut water.
Pickle juice or tonic water. I swear it works! I'd get up and drink some pickle juice out of the jar and then crawl back in bed and sleep great. I ate a ton of bananas (A TON) and I'm telling you, pickle juice is the answer! I mention tonic water because an old lady I know drinks a glass every night for her restless leg syndrome and she swears by it. I like pickles so it's a personal preference.
Leg cramps are usually caused by a potassium deficiency, being dehydrated or a combo of both. Drink plenty of water and eat bananas or other potassium rich foods.