This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function copyToClipboard(text) { | |
| if (window.clipboardData && window.clipboardData.setData) { | |
| // IE specific code path to prevent textarea being shown while dialog is visible. | |
| return clipboardData.setData("Text", text); | |
| } else if (document.queryCommandSupported && document.queryCommandSupported("copy")) { | |
| var textarea = document.createElement("textarea"); | |
| textarea.textContent = text; | |
| textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in MS Edge. | |
| document.body.appendChild(textarea); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://nodejs.org/api/http.html#http_http_get_options_callback | |
| const postData = querystring.stringify({ | |
| 'msg': 'Hello World!' | |
| }); | |
| const options = { | |
| hostname: 'www.google.com', | |
| port: 80, | |
| path: '/upload', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| http.get('http://nodejs.org/dist/index.json', (res) => { | |
| const { statusCode } = res; | |
| const contentType = res.headers['content-type']; | |
| let error; | |
| if (statusCode !== 200) { | |
| error = new Error('Request Failed.\n' + | |
| `Status Code: ${statusCode}`); | |
| } else if (!/^application\/json/.test(contentType)) { | |
| error = new Error('Invalid content-type.\n' + |