As an alternative to @mplungian's solution, you could use semicolon separation:
data:text/html,<script>fetch('https://www.example.com/') .then(r => r.text()) .catch(e => console.log(e)); location.href = 'https://www.example.com/'</script>