1 John 3:22
And whatsoever we ask, we receive of him, because we keep his commandments, and do those things that are pleasing in his sight.
This is a conditional promise. To keep His commandments is to abide in Him and to live in close, vital intimacy with Him. When we are in fellowship with Him, we make His will our own will. When we ask according to His will, we receive from Him the things we ask for.