You can store data in
.json
files and deploy them with your application, then load the data
Using the Fetch API - Web APIs | MDN[
^]
This allows you to make a background request to load a resource from a provided path or URL, then deserialize the content. You could store your month values as JSON, in the format:
["January", "February", "March", ..]
Then simply load the data.
Here's an example JSFiddle which loads an array of monarchs[
^] from a public JSON file. By calling the
await fetch()
the JS will return a response, and then further calling
await response.json()
we then convert the fetched data into a JSON object.
Just remember that if you're testing from a simple
.html
file in your browser, the browser may not allow access to files on the file system. In those cases you'd probably need to deploy the HTML and JS files as part of a webserver (ie. Node)