Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. // vscode custom snippet
  2. /*
  3. - Ajax request.
  4. - Proxy function.
  5. - Promise with try catch.
  6. - Function, Promise and try catch.
  7. */
  8. {
  9. "Try promise": {
  10. "prefix": [
  11. "promise",
  12. "promise-const"
  13. ],
  14. "body": [
  15. "return new Promise((resolve, reject) => {",
  16. "\ttry {",
  17. "\t\t",
  18. "\t} catch (error) {",
  19. "\t\t",
  20. "\t};",
  21. "});"
  22. ],
  23. "description": "Promise with try catch..."
  24. },
  25.  
  26. "Const function promise": {
  27. "prefix": [
  28. "function promise",
  29. "function-promise-const"
  30. ],
  31. "body": [
  32. "// nameFunction - Description",
  33. "",
  34. "const nameFunction = function () {",
  35. "\treturn new Promise((resolve, reject) => {",
  36. "\t\ttry {",
  37. "\t\t\t",
  38. "\t\t} catch (error) {",
  39. "\t\t\t",
  40. "\t\t};",
  41. "\t});",
  42. "};"
  43. ],
  44. "description": "Function with promise and try-catch"
  45. },
  46.  
  47. "Proxy function": {
  48. "prefix": [
  49. "proxy function",
  50. "proxy-function-const"
  51. ],
  52. "body": [
  53. "this.NameFunction = function NameFunction() {",
  54. "\ttry {",
  55. "\t\t",
  56. "\t} catch (error) {",
  57. "\t\t",
  58. "\t};",
  59. "};"
  60. ],
  61. "description": "Function with promise and try-catch"
  62. },
  63.  
  64. "Ajax request": {
  65. "prefix": [
  66. "ajax request",
  67. "ajax-request-const"
  68. ],
  69. "body": [
  70. "$.ajax({",
  71. "\ttype: \"POST\",",
  72. "\turl: \"url\",",
  73. "\tdata: JSON.stringify(data),",
  74. "\tcontentType: \"application/json; charset=utf-8\",",
  75. "\tdataType: \"json\",",
  76. "\tsuccess: function success(res) {",
  77. "\t\t",
  78. "\t},",
  79. "\terror: function error(err) {",
  80. "\t\t",
  81. "\t}",
  82. "});"
  83. ],
  84. "description": "Function with promise and try-catch"
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement