Imagine if God were to come to you today and say, "Ask what you want, and I will give it to you." That is what happened to Solomon. But because Solomon had his priorities in order, he responded in the right way. He said,
"Now, O Lord my God, You have made Your servant king instead of my father David, but I am a little child; I do not know how to go out or come in. And Your servant is in the midst of Your people whom You have chosen, a great people, too numerous to be numbered or counted. Therefore give to Your servant an understanding heart to judge Your people, that I may discern between good and evil. For who is able to judge this great people of Yours?" (1 Kings 3:7–9)
Solomon's answer pleased God, and God gave him what he asked for. You might wonder, Would God ever do that for me?
Yes, He would. But let's not miss the condition. Jesus said, "If you abide in Me, and My words abide in you, you will ask what you desire, and it shall be done for you" (John 15:7).
If you are walking in close fellowship with God, and His Word is at home in your heart, then you will pray for things that bring God glory. If you are praying for self-indulgent things, then it would be doubtful that you are maintaining a living communion with Him and that His Word is at home in you.
Prayer is aligning ourselves with the will of God.