Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // vscode custom snippet
- /*
- - Ajax request.
- - Proxy function.
- - Promise with try catch.
- - Function, Promise and try catch.
- */
- {
- "Try promise": {
- "prefix": [
- "promise",
- "promise-const"
- ],
- "body": [
- "return new Promise((resolve, reject) => {",
- "\ttry {",
- "\t\t",
- "\t} catch (error) {",
- "\t\t",
- "\t};",
- "});"
- ],
- "description": "Promise with try catch..."
- },
- "Const function promise": {
- "prefix": [
- "function promise",
- "function-promise-const"
- ],
- "body": [
- "// nameFunction - Description",
- "",
- "const nameFunction = function () {",
- "\treturn new Promise((resolve, reject) => {",
- "\t\ttry {",
- "\t\t\t",
- "\t\t} catch (error) {",
- "\t\t\t",
- "\t\t};",
- "\t});",
- "};"
- ],
- "description": "Function with promise and try-catch"
- },
- "Proxy function": {
- "prefix": [
- "proxy function",
- "proxy-function-const"
- ],
- "body": [
- "this.NameFunction = function NameFunction() {",
- "\ttry {",
- "\t\t",
- "\t} catch (error) {",
- "\t\t",
- "\t};",
- "};"
- ],
- "description": "Function with promise and try-catch"
- },
- "Ajax request": {
- "prefix": [
- "ajax request",
- "ajax-request-const"
- ],
- "body": [
- "$.ajax({",
- "\ttype: \"POST\",",
- "\turl: \"url\",",
- "\tdata: JSON.stringify(data),",
- "\tcontentType: \"application/json; charset=utf-8\",",
- "\tdataType: \"json\",",
- "\tsuccess: function success(res) {",
- "\t\t",
- "\t},",
- "\terror: function error(err) {",
- "\t\t",
- "\t}",
- "});"
- ],
- "description": "Function with promise and try-catch"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement