Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <h1>Guestbook</h1>
- <div id='posts'>
- </div>
- <hr />
- <form action='/post' method='post'>
- <input type='text' name='username' placeholder='Username' /><br />
- <textarea name='post' placeholder='Post text'></textarea><br />
- <input type='submit' />
- </form>
- <script>
- document.body.onload = () =>
- void fetch('/posts')
- .then(posts => posts.json())
- .then(posts => posts.map(
- ({username, post}) => `
- <div>
- <b>${username}</b><br />
- ${post}
- </div>
- `))
- .then(posts => posts.join('<br />'))
- .then(posts => void (document.getElementById('posts').innerHTML = posts))
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement