I am looking to import data from a local JSON file into a state value setting within my Vue.js application.
store/index.js
import { createStore} from 'vuex'
export default createStore({
state: {
settings: {}
}
})
assets/json/settings.json
{
"theme": "dark",
"loggedIn": true,
"mobile": false,
}
I need the imported data to be reactive so that it can work with computed properties in my Vue components. Ideally, I would like to find a way to save changes back to the JSON file using something like fs. I am utilizing Vuex for managing the data across multiple components.
How can I assign the values from the JSON file to the state.settings variable? 😅