Deleting Posts using Route Slugs
Fullstack Social iOS NodeJS REST
Now that our browser is properly hooked up to delete post objects, let's create a proper route that handles a DELETE request. This request will simply delete objects using the Waterline destroy command. Once the object is deleted, let's update our UI to make sure it is removed from the DOM.

Comments (3)
Bobur Pakhriev
3 years ago
Hi Brian, i came across with this kind of error on my console Download the Vue Devtools extension for a better development experience: https://github.com/vuejs/vue-devtools vue.js:9058 You are running Vue in development mode. Make sure to turn on production mode when deploying for production. See more tips at https://vuejs.org/guide/deployment.html vue.js:8585 You are running Sails + Vue.js in development mode. (To enable production mode for Vue.js, lift Sails in production.) [?] More tips at https://sailsjs.com/docs/concepts/deployment sails.io.js:441 |> Now connected to http://localhost:1337. \___/ For help, see: http://bit.ly/2q0QDpf (using sails.io.js browser SDK @v1.2.1) Connected at: Tue Nov 12 2019 14:17:12 GMT+0900 (Korean Standard Time) spread.js:25 DELETE http://localhost:1337/post 404 (Not Found) (anonymous) @ spread.js:25 e.exports @ spread.js:25 e.exports @ spread.js:25 Promise.then (async) r.request @ spread.js:25 r.<computed> @ spread.js:25 (anonymous) @ axios.min.js:477 deletePost @ post:830 click @ VM3204:1 invokeWithErrorHandling @ vue.js:1863 invoker @ vue.js:2188 original._wrapper @ vue.js:7541 spread.js:25 Uncaught (in promise) Error: Request failed with status code 404 at e.exports (spread.js:25) at e.exports (spread.js:25) at XMLHttpRequest.d.onreadystatechange (spread.js:25) e.exports @ spread.js:25 e.exports @ spread.js:25 d.onreadystatechange @ spread.js:25 XMLHttpRequest.send (async) (anonymous) @ spread.js:25 e.exports @ spread.js:25 e.exports @ spread.js:25 Promise.then (async) r.request @ spread.js:25 r.<computed> @ spread.js:25 (anonymous) @ axios.min.js:477 deletePost @ post:830 click @ VM3204:1 invokeWithErrorHandling @ vue.js:1863 invoker @ vue.js:2188 original._wrapper @ vue.js:7541
Brian Voong
3 years ago
AlfieLBTA
3 years ago
Hey Brian good afternoon - in the last try catch code, how is it different from : axios.get('/user?ID=12345') .then(function (response) { // handle success console.log(response); }) .catch(function (error) { // handle error console.log(error); }) is one better than the other in any way? or just programer preference ? And second are you showing how to use promises on future lectures?
Brian Voong
3 years ago
AlfieLBTA
3 years ago
Gotcha! thanks for such an awesome course man.
gerkov77
3 years ago
Hey Brian, unfortunately the same thing happened again with the MongoDB Atlas connection. Yesterday I have created a new cluster and it was working, and I have completed lesson 17 with Vue.js. Today I cannot connect with the app or with Compass. Are these clusters for only one day maybe? Compass' message after failing to connect: 'connection <monitor> to 52.58.45.150:27017 closed'
gerkov77
3 years ago
Ok, I think I have some kind of answer to that! On Mongo Atlas one has to whitelist their IP address for letting connect. It is a 'hardcoded' setting, but my public IP is changing from time to time. ( I am not sure why, since i am not an expert of the topic). So when I am whitelisting my IP, the problem seems to be solved. Only It would be nice not having to update the IP manually everytime it changes. We do not know when it changes, so this can become uncontrolled. The other option is letting connect from every IP, which I am not really comfortable doing yet.
Brian Voong
3 years ago
HELP & SUPPORT