-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Phase 5 - Vue TodoMVC modifications for rest model
1. `npm install axios --save` modify package.json per example and run npm install 2. modify vue-app/config/index.js to change port to 8090 so it doesn't conflict with grails 3. create new src/todoRestApi.js for communication with grails. See file. 4. modify src/main.js to use the new todoModel.js instead of the local storage `todoStorage` from original example 5. Make minor tweak to the complete check box to use even for save 5. `grails run-app` under the grail-server dir. In another shell window cd to vue-app and run 'npm run dev'
- Loading branch information
Showing
5 changed files
with
88 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import axios from 'axios' | ||
//import async from 'async' | ||
|
||
const RestAx = axios.create({ | ||
baseURL: 'http://localhost:8080/api/' | ||
}) | ||
|
||
export default { | ||
|
||
list: todos => { | ||
RestAx.get(`todo`).then(response => { | ||
todos.push(...response.data) | ||
console.log("list ", todos) | ||
}) | ||
}, | ||
|
||
save: todo => { | ||
console.log("saving", todo) | ||
RestAx.post('todo', todo).then(response => { | ||
console.log("Saved", response) | ||
todo.id = response.data.id | ||
}) | ||
}, | ||
|
||
update: todo => { | ||
console.log("updating", todo) | ||
RestAx.put('todo/' + todo.id, todo).then(response => { | ||
console.log("updated", response) | ||
}) | ||
}, | ||
|
||
delete: todo => { | ||
console.log("deleting", todo) | ||
RestAx.delete('todo/' + todo.id).then(response => { | ||
console.log("deleted", response) | ||
}) | ||
}, | ||
|
||
updateAll: todos => { | ||
console.log("updating", todos) | ||
todos.forEach(function (todo) { | ||
RestAx.put('todo/' + todo.id, todo).then(response => { | ||
console.log("Updated", response) | ||
//callback(null, response.data) | ||
}) | ||
}) | ||
}, | ||
|
||
archiveCompleted: todos => { | ||
console.log("archiveCompleted", todos) | ||
|
||
todos.filter(function (todo) { | ||
return todo.completed | ||
}).forEach(function (todo) { | ||
RestAx.delete('todo/' + todo.id).then(response => { | ||
todos.splice(todos.indexOf(todo), 1) | ||
console.log("deleted", todo) | ||
}) | ||
}) | ||
} | ||
} |