Created
December 4, 2016 18:56
-
-
Save horacioibrahim/f4778164104cdbd415b2785b09b1e657 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| firebase.database().ref('transactions/').push(data).then(function(res){ // PUSH 1 | |
| firebase.database().ref('users/' + user.uid + '/transactions/' + res.key).set({dtCreated: data.dtCreated}).then( | |
| function(res2){ // AFTER PUSH 2 | |
| console.log("Gravou nos 2"); | |
| window.location.href = "#/dashboard/history"; | |
| }, function(err2) { | |
| var error = { | |
| canceled: true, | |
| log: "transaction not registered in owner attributes." | |
| }; | |
| // WORKAROUND IF ERROR | |
| firebase.database().ref('transactions/' + res.key).update(error).then(function(resRemoved){ | |
| console.log("removido!" + resRemoved); | |
| }); | |
| toast.message = "Problemas ao gravar sua transação"; | |
| tpl.toastOn(); | |
| } | |
| ); | |
| }, function(err) { | |
| console.log(err); | |
| toast.message = "Problema ao gravar a transação"; | |
| tpl.toastOn(); | |
| } | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment