Retrive image with URL paramter and javascript

Sadly, I have not enough experience in JS to do this.

I want to call the Google chart API with my URL paramter as data.
Here I used Javascript to store the URL paramter ‘voucher’ in a variable from my Website:

mywebsite.com/core/voucher/?voucher=123

This is the code I use:

<script>
    const queryString = window.location.search;
    const urlParams = new URLSearchParams(queryString);
    const voucher= urlParams.get('voucher');
   //voucher = 123
</script>

<img id="qr" src="https://chart.apis.google.com/chart?cht=qr&chs=400x400&chl=1"/>

Now I need the ‘voucher’ variable to call the Google chart URL with my variable as the chl URL paramter. How can i archive this?