deleteUser: async function() { console.log("[=>] DELETE USER!"); const API_SERVER = "http://localhost:3000/users/"; try { const response = await axios.delete( API_SERVER + this.$route.params.id, { headers: { Authorization: "Bearer " + localStorage.getItem("token"), }, } ); console.log(response); // remove user from local storage localStorage.removeItem("username"); localStorage.removeItem("userId"); localStorage.removeItem("token"); setTimeout(() => this.$router.push("/"), 3000); } catch (error) { this.errors.push(error); } },
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter