Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.81 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7.     <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  8.     <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  9.     <title>Index page</title>
  10. </head>
  11. <body>
  12.     <div id="root">
  13.         {{ topics }}
  14.     </div>
  15.     <script>
  16.         new Vue({
  17.             el: "#root",
  18.             data: {
  19.                 topics: []
  20.             },
  21.             mounted() {
  22.                 axios.get('/topics')
  23.                 .then(function(response) {
  24.                     alert(response.data[0].heading)
  25.                     this.topics = response.data
  26.                 })
  27.                 .catch(function(error) {
  28.                     console.log(error)
  29.                 });
  30.             }
  31.         });
  32.     </script>
  33. </body>
  34. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement