jgravois
187
5
Vue

Adding Newly Inserted Record to list

Posted 3 years ago by jgravois

I just inserted a record into the database and Laravel is passing the entire record back to me. I need to insert the newly created record into the list. This is my saveNew method in my .vue file and the line I need help with is “this.certs.push(newbie.data);” because that’s not the right way.

               var path = '/api/certs/new';
               var data = {name: this.newname};
               this.$http.post(path, data)
                   .then(function(newbie) {
                       this.certs.push(newbie.data);
                       this.newname = '';
                       this.newcert = false;
                   });

               return false;
           },

I am getting this error: Uncaught (in promise) TypeError: this.certs.push is not a function(…)

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.