How to ask God: If we know that he hears us we know that we have what we asked of him, 1 John 5:15
The Bible teaches us how to ask God in prayer, an example of this is the Lord's Prayer taught by Jesus. The Our Father begins by acknowledging God's sovereignty over the world, that is his kingdom among the hearts of men: "Our Father in heaven, hallowed be your name, your kingdom come, your will be done, on earth as it is in heaven" Matthew 6:9-10. Second, we request the mercy (compassion, gentleness, kindness) of God, just as we are merciful with our brothers, here we request a retribution (law of the sowing and reaping, Galatians 6:7), his perfect listening, and so request him: "And forgive us our debts, as we also have forgiven our debtors." Matthew 6:12.
And finally, with what we ask we will not sin, that is, we ask wisely to God and without selfishness: "And lead us not into temptation, but deliver us from the evil one" Matthew 6:13.
When we pray to God asking for something, what we ask has to have a logic, if we ask following our own passions it is certain that we will not receive anything, the apostle John explains it in his first epistle: "This is the confidence we have in approaching God: that if we ask anything according to his will, he hears us. And if we know that he hears us—whatever we ask—we know that we have what we asked of him" 1 John 5:14-15.
The like seeks the like, in other words: "And we know that in all things God works for the good of those who love him, who have been called according to his purpose" Romans 8:28.
For all this, when we fear God, Jesus tells us what we must do: "Ask and it will be given to you; seek and you will find; knock and the door will be opened to you. For everyone who asks receives; the one who seeks finds; and to the one who knocks, the door will be opened. Which of you, if your son asks for bread, will give him a stone? Or if he asks for a fish, will give him a snake? If you, then, though you are evil, know how to give good gifts to your children, how much more will your Father in heaven give good gifts to those who ask him!" Matthew 7:7-11