{"id":598,"date":"2024-05-14T05:00:20","date_gmt":"2024-05-14T05:00:20","guid":{"rendered":"https:\/\/www.freelifemakers.org\/wordpress\/?p=598"},"modified":"2024-05-14T12:42:35","modified_gmt":"2024-05-14T12:42:35","slug":"nodejs","status":"publish","type":"post","link":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/2024\/05\/14\/nodejs\/","title":{"rendered":"[NODEJS]GET \ubc29\uc2dd \ub370\uc774\ud130 \uc804\uc1a1 GET METHOD TRANSMISSION[QS,CDNJS]"},"content":{"rendered":"\n<p>\ub2e4\ub978 \ubd80\ubd84\uc740 \uc774\uc804 \ubd80\ubd84\ub4e4\uacfc \uc911\ubcf5\ub418\uae30 \ub54c\ubb38\uc5d0 \uc124\uba85\uc744 \uc0dd\ub7b5\ud569\ub2c8\ub2e4.<br>\uc911\uc694\ud558\uac8c \ubd10\uc57c \ud560 \ubd80\ubd84\uc740 \ub179\uc0c9 \uceec\ub7ec \ubd80\ubd84\uacfc \uac08\uc0c9 \uceec\ub7ec \ubd80\ubd84\uc785\ub2c8\ub2e4.<\/p>\n\n\n\n<p>The explanation of other parts is omitted because they overlap with the previous parts.<br>The important parts to look at are the green colored part and the brown colored part.<\/p>\n\n\n\n<p><strong>1.QS<\/strong><br>&#8211; get\ubc29\uc2dd \ub370\uc774\ud130 \uc804\uc1a1\uc744 \uc0ac\uc6a9\ud558\ub824\uba74 qs\ubaa8\ub4c8\uc774 \ud544\uc694\ud55c\ub370 \uc11c\ubc84\ubd80\ubd84\uc740 \ubaa8\ub4c8\uc744 \uc124\uce58\ud574\uc57c \ud558\ub098 \ud074\ub77c\uc774\uc5b8\ud2b8 \ubd80\ubd84\uc740 cdnjs\uc5d0\uc11c cdn\ubc29\uc2dd\ub9c1\ud06c\ub85c \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<br>&#8211; <a rel=\"noreferrer noopener\" href=\"https:\/\/cdnjs.com\" target=\"_blank\">https:\/\/cdnjs.com<\/a> \uc5d0\uc11c \uc544\ub798\uc758 \ucf54\ub4dc\ub97c \ubc1b\uc744 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n\n\n\n<p>&#8211; To use get-type data transmission, the qs module is required. The server part requires the module to be installed, but the client part can be used as a cdn-style link in cdnjs.<br>&#8211; You can get the code below from https:\/\/cdnjs.com.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>        &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/qs\/6.12.1\/qs.min.js\" \n        integrity=\"sha512-vuLOE4Fh9lfxaN9n81Vl1HwrqMYz9WKoNmsHNC7Hz7OWX4k4O7FjCyQ1tQ82RJExao+Fas40RLiS5PCfVRGgnQ==\" \n        crossorigin=\"anonymous\" referrerpolicy=\"no-referrer\"&gt;&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<p>&#8211; querystring\uc5d0\uc11c id,name\uc744 \uac00\uc9c0\uace0 \uc635\ub2c8\ub2e4.<br>&#8211; querysting\uc740 \uc8fc\uc18c\uc758 ?\uc640 \uadf8 \ub4b7 \ubd80\ubd84\uc744 \uc758\ubbf8\ud569\ub2c8\ub2e4. <br>&#8211; ignoreQueryPrefix: true \uc774 \uc635\uc158\uc740 querystring\uc5d0\uc11c ?\ub97c \uc81c\uac70\ud558\ub294 \uc635\uc158\uc785\ub2c8\ub2e4.<\/p>\n\n\n\n<p>&#8211; Get id and name from querystring.<br>&#8211; querysting means the ? and the part after it in the address.<br>&#8211; ignoreQueryPrefix: true This option removes ? from the querystring.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>            const { id, name } = Qs.parse(location.search, {\n                ignoreQueryPrefix: true,\n            });<\/code><\/pre>\n\n\n\n<p><strong>2.\uc804\uccb4\ucf54\ub4dc(full coce)<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server_data.js\n\n\/\/server_data.js\nconst http = require('http');\nconst express = require('express');\nconst app = express();\nconst server = http.createServer(app);\n\n\/*  routing  *\/\napp.use(express.static(__dirname+\"\/public\"));\n\n\n\/\/ Start the server\nconst PORT = process.env.PORT || 3000;\nserver.listen(PORT, () =&gt; {\n  console.log(`CommonJS(Express) Server is running on port ${PORT}`);\n});\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>index.html\n\n&lt;html&gt;\n    &lt;head&gt;    \n        &lt;title&gt;index.html&lt;\/title&gt;\n    &lt;\/head&gt;\n    &lt;body&gt;\n      &lt;a href=\"get.html?id=202405&amp;name=hellowworld!\"&gt;querystring&lt;\/a&gt;\n    &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>get.html\n\n&lt;html&gt;\n    &lt;head&gt;    \n        &lt;title&gt;get.html&lt;\/title&gt;\n    &lt;\/head&gt;\n    &lt;body&gt;\n        &lt;div id=\"getid\"&gt;&lt;\/div&gt;\n        &lt;div id=\"getname\"&gt;&lt;\/div&gt;\n    &lt;\/body&gt;\n\n        &lt;!--https:\/\/cdnjs.com\/libraries\/qs--&gt;\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-green-color\">        &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/qs\/6.12.1\/qs.min.js\" \n        integrity=\"sha512-vuLOE4Fh9lfxaN9n81Vl1HwrqMYz9WKoNmsHNC7Hz7OWX4k4O7FjCyQ1tQ82RJExao+Fas40RLiS5PCfVRGgnQ==\" \n        crossorigin=\"anonymous\" referrerpolicy=\"no-referrer\"&gt;&lt;\/script&gt;<\/mark>\n        &lt;script&gt;    \n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-green-color\">            const { id, name } = Qs.parse(location.search, {\n                ignoreQueryPrefix: true,\n            });<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#c2b30c\" class=\"has-inline-color\"> <\/mark><mark style=\"background-color:rgba(0, 0, 0, 0);color:#ae640b\" class=\"has-inline-color\">           document.getElementById('getid').innerHTML = `${id}`;\n            document.getElementById('getname').innerHTML = `${name}`;<\/mark>\n            console.log(id,name);\n        &lt;\/script&gt;\n\n&lt;\/html&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\ub2e4\ub978 \ubd80\ubd84\uc740 \uc774\uc804 \ubd80\ubd84\ub4e4\uacfc \uc911\ubcf5\ub418\uae30 \ub54c\ubb38\uc5d0 \uc124\uba85\uc744 \uc0dd\ub7b5\ud569\ub2c8\ub2e4.\uc911\uc694\ud558\uac8c \ubd10\uc57c \ud560 \ubd80\ubd84\uc740 \ub179\uc0c9 \uceec\ub7ec \ubd80\ubd84\uacfc \uac08\uc0c9 \uceec\ub7ec \ubd80\ubd84\uc785\ub2c8\ub2e4. The explanation of other parts is omitted because they overlap with the previous parts.The important parts to look at are the green colored part and the brown colored part. 1.QS&#8211; get\ubc29\uc2dd \ub370\uc774\ud130 \uc804\uc1a1\uc744 \uc0ac\uc6a9\ud558\ub824\uba74 qs\ubaa8\ub4c8\uc774 \ud544\uc694\ud55c\ub370 \uc11c\ubc84\ubd80\ubd84\uc740 \ubaa8\ub4c8\uc744 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-598","post","type-post","status-publish","format-standard","hentry","category-nodejs","missing-thumbnail"],"_links":{"self":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/598","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=598"}],"version-history":[{"count":7,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/598\/revisions"}],"predecessor-version":[{"id":606,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/598\/revisions\/606"}],"wp:attachment":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}