Skip to content

Instantly share code, notes, and snippets.

@bradtraversy
Last active September 3, 2025 00:32
Show Gist options
  • Save bradtraversy/c3d5c35e77633601bc0ce5646d584fc9 to your computer and use it in GitHub Desktop.
Save bradtraversy/c3d5c35e77633601bc0ce5646d584fc9 to your computer and use it in GitHub Desktop.

Revisions

  1. bradtraversy revised this gist Feb 28, 2019. 1 changed file with 60 additions and 82 deletions.
    142 changes: 60 additions & 82 deletions vsc_js_snippets.json
    Original file line number Diff line number Diff line change
    @@ -1,75 +1,53 @@
    {
    "Console Log": {
    "prefix": "cl",
    "body": "console.log($1);",
    "description": "Console Log"
    },
    "Named Function": {
    "prefix": "nfn",
    "body": [
    "function ${1:functionName}($2) {",
    " $3",
    "}"
    ],
    "description": "Named Function"
    },
    "Anonymous Function": {
    "Console Log": {
    "prefix": "cl",
    "body": "console.log($1);",
    "description": "Console Log"
    },
    "Named Function": {
    "prefix": "nfn",
    "body": ["function ${1:functionName}($2) {", " $3", "}"],
    "description": "Named Function"
    },
    "Anonymous Function": {
    "prefix": "fn",
    "body": [
    "function() {",
    " $2",
    "}"
    ],
    "body": ["function() {", " $2", "}"],
    "description": "Anonymous Function"
    },
    "Arrow Function": {
    "prefix": "arfn",
    "body": [
    "const ${1:functionName} = ($2) => {",
    " $3",
    "}"
    ],
    "description": "Arrow Function"
    },
    "Basic If Statement": {
    "Arrow Function": {
    "prefix": "arfn",
    "body": ["const ${1:functionName} = ($2) => {", " $3", "}"],
    "description": "Arrow Function"
    },
    "Basic If Statement": {
    "prefix": "ifc",
    "body": [
    "if(${1:condition}) {",
    " $2",
    "}"
    ],
    "body": ["if(${1:condition}) {", " $2", "}"],
    "description": "If Statement"
    },
    "If Else Statement": {
    "prefix": "ifelsec",
    "body": [
    "if(${1:condition}) {",
    " $2",
    "} else {",
    " $3",
    "}"
    ],
    "body": ["if(${1:condition}) {", " $2", "} else {", " $3", "}"],
    "description": "If else statement"
    },
    "Array Method": {
    "prefix": "arrmth",
    "body": [
    "${1|forEach,map,filter,reduce,some|}((${2:item}) => {",
    " $3",
    "})"
    ],
    "description": "Array Method"
    },
    "Axios Request": {
    "prefix": "axreq",
    "body": [
    "axios.${1|get,post,put,delete|}('${2:url}')",
    " .then(res => console.log(res.data))",
    " .catch(err => console.log(err));"
    ],
    "description": "Axios Request"
    },
    "Fetch Request": {
    "Array Method": {
    "prefix": "arrmth",
    "body": [
    "${1|forEach,map,filter,reduce,some|}((${2:item}) => {",
    " $3",
    "})"
    ],
    "description": "Array Method"
    },
    "Axios Request": {
    "prefix": "axreq",
    "body": [
    "axios.${1|get,post,put,delete|}('${2:url}')",
    " .then(res => console.log(res.data))",
    " .catch(err => console.log(err));"
    ],
    "description": "Axios Request"
    },
    "Fetch Request": {
    "prefix": "fetchreq",
    "body": [
    "fetch('${1:url}')",
    @@ -78,7 +56,7 @@
    ],
    "description": "Fetch Request"
    },
    "asfetchreq": {
    "asfetchreq": {
    "prefix": "Async Await Fetch",
    "body": [
    "const request = async ($1) => {",
    @@ -89,29 +67,29 @@
    ],
    "description": "Fetch Async/Await"
    },
    "Node Require": {
    "Node Require": {
    "prefix": "ndrq",
    "body": "const ${1:import} = require('${module}');",
    "description": "Require a Node.js module"
    },
    "Express Server": {
    "prefix": "expsrv",
    "body": [
    "const express = require('express');",
    "",
    "const app = express();",
    "",
    "app.${1|get,post,put,delete|}('${2:route}', (req, res) => {",
    " $3",
    "});",
    "",
    "const PORT = process.env.PORT || ${4|3000,5000,8000,8080|};",
    "",
    "app.listen(PORT, () => console.log(`Server Running On Port ${PORT}`));"
    ],
    "description": "Express Server"
    },
    "Express Route": {
    "Express Server": {
    "prefix": "expsrv",
    "body": [
    "const express = require('express');",
    "",
    "const app = express();",
    "",
    "app.${1|get,post,put,delete|}('${2:route}', (req, res) => {",
    " $3",
    "});",
    "",
    "const PORT = process.env.PORT || ${4|3000,5000,8000,8080|};",
    "",
    "app.listen(PORT, () => console.log(`Server Running On Port ${PORT}`));"
    ],
    "description": "Express Server"
    },
    "Express Route": {
    "prefix": "exprt",
    "body": "app.${1|get,post,put,delete|}('${3:/}', (req, res) => {});",
    "description": "Express Route"
    @@ -121,4 +99,4 @@
    "body": "app.use(${1:middleware});",
    "description": "Express Middleware"
    }
    }
    }
  2. bradtraversy created this gist Feb 28, 2019.
    124 changes: 124 additions & 0 deletions vsc_js_snippets.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,124 @@
    {
    "Console Log": {
    "prefix": "cl",
    "body": "console.log($1);",
    "description": "Console Log"
    },
    "Named Function": {
    "prefix": "nfn",
    "body": [
    "function ${1:functionName}($2) {",
    " $3",
    "}"
    ],
    "description": "Named Function"
    },
    "Anonymous Function": {
    "prefix": "fn",
    "body": [
    "function() {",
    " $2",
    "}"
    ],
    "description": "Anonymous Function"
    },
    "Arrow Function": {
    "prefix": "arfn",
    "body": [
    "const ${1:functionName} = ($2) => {",
    " $3",
    "}"
    ],
    "description": "Arrow Function"
    },
    "Basic If Statement": {
    "prefix": "ifc",
    "body": [
    "if(${1:condition}) {",
    " $2",
    "}"
    ],
    "description": "If Statement"
    },
    "If Else Statement": {
    "prefix": "ifelsec",
    "body": [
    "if(${1:condition}) {",
    " $2",
    "} else {",
    " $3",
    "}"
    ],
    "description": "If else statement"
    },
    "Array Method": {
    "prefix": "arrmth",
    "body": [
    "${1|forEach,map,filter,reduce,some|}((${2:item}) => {",
    " $3",
    "})"
    ],
    "description": "Array Method"
    },
    "Axios Request": {
    "prefix": "axreq",
    "body": [
    "axios.${1|get,post,put,delete|}('${2:url}')",
    " .then(res => console.log(res.data))",
    " .catch(err => console.log(err));"
    ],
    "description": "Axios Request"
    },
    "Fetch Request": {
    "prefix": "fetchreq",
    "body": [
    "fetch('${1:url}')",
    " .then(res => res.json())",
    " .then(data => console.log(data));"
    ],
    "description": "Fetch Request"
    },
    "asfetchreq": {
    "prefix": "Async Await Fetch",
    "body": [
    "const request = async ($1) => {",
    " const response = await fetch('${2:url}');",
    " const data = await response.json();",
    " console.log(data);",
    "}"
    ],
    "description": "Fetch Async/Await"
    },
    "Node Require": {
    "prefix": "ndrq",
    "body": "const ${1:import} = require('${module}');",
    "description": "Require a Node.js module"
    },
    "Express Server": {
    "prefix": "expsrv",
    "body": [
    "const express = require('express');",
    "",
    "const app = express();",
    "",
    "app.${1|get,post,put,delete|}('${2:route}', (req, res) => {",
    " $3",
    "});",
    "",
    "const PORT = process.env.PORT || ${4|3000,5000,8000,8080|};",
    "",
    "app.listen(PORT, () => console.log(`Server Running On Port ${PORT}`));"
    ],
    "description": "Express Server"
    },
    "Express Route": {
    "prefix": "exprt",
    "body": "app.${1|get,post,put,delete|}('${3:/}', (req, res) => {});",
    "description": "Express Route"
    },
    "Express Init Middleware": {
    "prefix": "exmw",
    "body": "app.use(${1:middleware});",
    "description": "Express Middleware"
    }
    }