I'm trying to pass an API Key - which I call on the server side and pass through to an EJS file - into the src attribute on a script tag. When I console.log the string it prints exactly how'd I want but I can't update the src attribute the way I need to, to be able to run the script. I've tried passing in the string variable directly, using template literals etc. Any ideas?
<script>
let myKey = <%- JSON.stringify(key) %>
let string = `https://maps.googleapis.com/maps/api/js?key=${myKey}&callback=initMap`
</script>
<script src= https://maps.googleapis.com/maps/api/js?key=${myKey}&callback=initMap
async defer> </script