{
    "script:setup": {
        "prefix": "script:setup",
        "body": [
            "<script setup lang=\"ts\">",
            "\t$1",
            "</script>"
        ],
        "description": "Setup the basic structure of a class in JS"
    },
	"JSAsync": {
		"prefix": "jsAsync",
		"body": "(async () => {\n$1\n} ) ();"
	},
	"JSpromiseReturnFunc": {
		"prefix": "jsPromise",
		"body": "function $1 () {\n\treturn new Promise( ( resolve, reject ) => {\n\t$2\n\t} );\n}"
	},
	"fetch from other url": {
		"prefix": "remoteURL",
		"body": [
			"localStorage.getItem( 'url' ) + '/$1'"
		],
		"description": "remote URL fetching (get from base address from local storage)"
	},
	"fetch post": {
		"prefix": "fetchPost",
		"body": [
			"const fetchOptions = {",
			"\tmethod: 'post',",
			"\tbody: JSON.stringify( $1 ),",
			"\tcredentials: 'include',",
			"\theaders: {",
			"\t\t'Content-Type': 'application/json',",
			"\t\t'charset': 'utf-8'",
			"\t}",
			"};",
			"fetch( $2, fetchOptions ).then( res => {",
			"\tif ( res.status === 200 ) {",
			"\t\tres.json().then( json => {",
			"\t\t\t$3",
			"\t\t} );",
			"\t}",
			"} );",
			"$4"
		],
		"description": "POST request using fetch"
	},
	"fetch get": {
		"prefix": "fetchGet",
		"body": [
			"fetch( $2, { credentials: 'include' } ).then( res => {",
			"\tif ( res.status === 200 ) {",
			"\t\tres.json().then( json => {",
			"\t\t\t$3",
			"\t\t} );",
			"\t}",
			"} );",
			"$4"
		],
		"description": "POST request using fetch"
	},
	"promise": {
		"prefix": "promise",
		"body": [
			"return new Promise( ( resolve, reject ) => {",
			"\t",
			"} );"
		]
	}
}
