There are so many tutorials out there that add API_KEY to code.
And some other people now use their keys. Don't do that again.
π’ Do this instead π
const API_NAME = "myAPI";
const API_KEY = prompt ("Enter your API_KEY:");
This gives you the chance to test your code and learners can create their API_KEY to test it.
Note: This is only for the browser π.
You can further explain the normal way to do it and why you do it that way not to confuse learners.
Thank me later π€©.
Top comments (3)
I use dotenv for keys and others sensitive data πͺπΌ
How did you use dotenv in the browser?
I'm not using
dotenv
in browser, but useful for projects and to build a website like on Netlify.I prefer to use
localStorage
with an HTML input, for that.There is an example to get your Last.fm stats.
In my form, I'm getting the input of the key :
And I register it in the
localStorage
like this :If you are curious about this code, you can check that here π₯³
Also created a post about this project
Integrate Last.fm API with Vue.js
Thomas Bnt γ» Nov 5 '22 γ» 4 min read
Some comments have been hidden by the post's author - find out more