Compare commits

..

No commits in common. "1ace58745854e93d783bd44ed670f943df685f8d" and "6aa5105c48e55a9decfc4dac4d2a9b64c06a9fdf" have entirely different histories.

7 changed files with 9 additions and 43 deletions

View File

@ -1,8 +0,0 @@
{
"notes": [
{
"id": 1,
"text": "This note is from the db.json file!"
}
]
}

11
package-lock.json generated
View File

@ -2616,14 +2616,6 @@
"integrity": "sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA==", "integrity": "sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA==",
"dev": true "dev": true
}, },
"axios": {
"version": "0.20.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz",
"integrity": "sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==",
"requires": {
"follow-redirects": "^1.10.0"
}
},
"babel-eslint": { "babel-eslint": {
"version": "10.1.0", "version": "10.1.0",
"resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.1.0.tgz", "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.1.0.tgz",
@ -5629,7 +5621,8 @@
"follow-redirects": { "follow-redirects": {
"version": "1.13.0", "version": "1.13.0",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz",
"integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==" "integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==",
"dev": true
}, },
"for-in": { "for-in": {
"version": "1.0.2", "version": "1.0.2",

View File

@ -8,7 +8,6 @@
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
"axios": "^0.20.0",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"vue": "^3.0.0-rc.10", "vue": "^3.0.0-rc.10",
"vuex": "^4.0.0-0" "vuex": "^4.0.0-0"

View File

@ -82,7 +82,6 @@ export default {
break break
} }
}) })
this.$store.commit('FETCH_NOTES')
} }
} }
</script> </script>

View File

@ -3,5 +3,6 @@ import App from './App.vue'
import store from './store/index.js' import store from './store/index.js'
window.app = createApp(App) window.app = createApp(App)
.use(store)
.use(store) .use(store)
.mount('#app') .mount('#app')

View File

@ -1,16 +0,0 @@
import axios from 'axios'
const apiClient = axios.create({
baseURL: 'http://localhost:3000',
withCredentials: false,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
}
})
export default {
getNotes() {
return apiClient.get('/notes')
}
}

View File

@ -1,5 +1,4 @@
import { createStore } from 'vuex' import { createStore } from 'vuex'
import NoteService from '@/services/NoteService.js'
export default createStore({ export default createStore({
state() { state() {
@ -9,13 +8,12 @@ export default createStore({
}, },
mutations: { mutations: {
FETCH_NOTES(state) { FETCH_NOTES(state) {
NoteService.getNotes() state.notes = [
.then(response => { {
state.notes = response.data id: 1,
}) text: 'Note loaded via mutation from Vuex!'
.catch(error => { }
console.log('There was an error:', error.response) ]
})
}, },
ADD_NOTE(state, note) { ADD_NOTE(state, note) {
state.notes.push(note) state.notes.push(note)