- fix Indexdb:

1) ReadAllData 'GET'  : OK
 2) InsertTodo 'POST'  : OK
 3) DeleteItem 'DELETE': OK
 4) Modify     'PATCH' : OK
This commit is contained in:
Paolo Arena
2019-02-03 00:51:58 +01:00
parent 185bd2657d
commit 5db5fb7dd0
5 changed files with 77 additions and 65 deletions

View File

@@ -77,12 +77,20 @@ namespace Actions {
}
async function dbSaveTodo(context, itemtodo: ITodo) {
console.log('dbSaveTodo', itemtodo)
return await dbInsertSaveTodo(context, itemtodo, 'PATCH')
}
async function dbInsertTodo(context, itemtodo: ITodo) {
return await dbInsertSaveTodo(context, itemtodo, 'POST')
}
async function dbInsertSaveTodo(context, itemtodo: ITodo, method) {
console.log('dbInsertSaveTodo', itemtodo, method)
let call = process.env.MONGODB_HOST + '/todos/' + itemtodo._id
const token = UserStore.state.idToken
let res = await Api.SendReq(call, UserStore.state.lang, token, 'PATCH', itemtodo)
let res = await Api.SendReq(call, UserStore.state.lang, token, method, itemtodo)
.then(function (res) {
return rescodes.OK
})
@@ -127,6 +135,7 @@ namespace Actions {
}
export const actions = {
dbInsertTodo: b.dispatch(dbInsertTodo),
dbSaveTodo: b.dispatch(dbSaveTodo),
dbLoadTodo: b.dispatch(dbLoadTodo),
dbDeleteTodo: b.dispatch(dbDeleteTodo),