Assign a linearGradient to a canvas background color

I have created a gradient, and wish to make it the background color of the canvas, but the canvas doesn’t work with it. the rectangle which I drew to ensure the validity of the gradient works just …