Page 458 - MDP2022-3
P. 458

})
                    },
                    fnSave()  {
                        let  apiUrl  =  this.$serverUrl  +  '/board'
                        this.form  =  {
                            "idx":  this.idx,
                            "title":  this.title,
                            "contents":  this.contents,
                            "author":  this.author
                        }
                        if  (this.idx  ===  undefined)  {
                            //INSERT
                            this.$axios.post(apiUrl,  this.form)
                            .then((res)  =>  {
                                alert('글이  저장되었습니다.')
                                this.fnView(res.data.idx)
                            }).catch((err)  =>  {
                                if  (err.message.indexOf('Network  Error')  >  -1)  {
                                    alert('네트워크가  원활하지  않습니다.\n잠시  후  다시  시도해주세요.')
                                }
                            })
                        }  else  {
                            //UPDATE
                            this.$axios.patch(apiUrl,  this.form)
                            .then((res)  =>  {
                                alert('글이  저장되었습니다.')
                                this.fnView(res.data.idx)
                            }).catch((err)  =>  {
                                if  (err.message.indexOf('Network  Error')  >  -1)  {
                                    alert('네트워크가  원활하지  않습니다.\n잠시  후  다시  시도해주세요.')
                                }
                            })
                        }
                    }
                }
            }
            </script>
            <style  scoped>
            </style>
   453   454   455   456   457   458   459   460   461   462   463