Skip to content

Instantly share code, notes, and snippets.

@guillaumecabanel
Last active April 30, 2020 11:49
Show Gist options
  • Save guillaumecabanel/f0570274a3cd5ec147de143d362d0b98 to your computer and use it in GitHub Desktop.
Save guillaumecabanel/f0570274a3cd5ec147de143d362d0b98 to your computer and use it in GitHub Desktop.
How to pass ENV variable to js file
/ your_view.html.slim
div#something data-api-key=(ENV['API_KEY'])
// your_file.js
const apiKey = document.getElementById('something').dataset.apiKey

⚠ Your API_KEY is exposed publicly in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment