Created
July 26, 2022 18:57
-
-
Save srele96/3441d42c1380ea0f161d54fa730bb2a8 to your computer and use it in GitHub Desktop.
Return JavaScript code from the server
This file contains 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
app.get('/js-code', (req, res) => { | |
res.send(` | |
console.log( | |
'Hi there! A script <script src="js-code"></script> will run me' | |
); | |
function iCanDoAnything() { | |
// i can add an element | |
const body = document.getElementsByTagName('body')[0]; | |
const h1 = document.createElement('h1'); | |
h1.innerText = 'Daayum! I really can do anything.'; | |
body.appendChild(h1); | |
} | |
iCanDoAnything(); | |
`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment