In the example TodoMVC, I understand I can hook into the fetch
and save
function to use jQuery Ajax Get/Post to interact with backend APIs for remote storage.
e.g.
var todoStorage = {
fetch: function () {
var todos = JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]')
todos.forEach(function (todo, index) {
todo.id = index
})
todoStorage.uid = todos.length
return todos
},
save: function (todos) {
localStorage.setItem(STORAGE_KEY, JSON.stringify(todos))
}
}
But since my backend is already restful API, are there any more elegant way to map my Restful Apis more neatly?