Advertisement
Jehanramadhan

Get Token

Jan 10th, 2017
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Data Realtime</title>
  5. <style type="text/css">
  6. table, td, th {
  7. border: 1px solid #ddd;
  8. font-size: 13px;
  9. font-family: helvetica;
  10. vertical-align: middle;
  11. text-align: center;
  12. }
  13. table {
  14. border-collapse: collapse;
  15. width: 100%;
  16. }
  17. th, td {
  18. padding: 15px;
  19. }
  20. th {
  21. background-color: #96E6F8;
  22. }
  23. </style>
  24. </head>
  25. <body>
  26. <div id="token">
  27. <input type="submit" v-on:click.prevent="getToken">
  28. <table>
  29. <tr>
  30. <th>No</th>
  31. <th>Road Name</th>
  32. <th>Local Date & Time</th>
  33. <th>Ignition Status</th>
  34. <th>Device Name</th>
  35. <th>RPM</th>
  36. <th>Speed</th>
  37. <th>Heading</th>
  38. <th>Longitude</th>
  39. <th>Latitude</th>
  40. <th>Geofences</th>
  41. <th>Mileage</th>
  42. </tr>
  43. <tr>
  44. <td v-for="route in route"> {{ route.no }} </td>
  45. </tr>
  46. </table>
  47. </div>
  48.  
  49. <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.8/vue.js"></script>
  50. <script src="https://cdn.jsdelivr.net/vue.resource/1.0.3/vue-resource.min.js"></script>
  51.  
  52. <script>
  53.  
  54. Vue.http.headers.common['X-CSRF-TOKEN'] = document.querySelector('#token').getAttribute('value');
  55.  
  56. var table = new Vue({
  57. el: '#token',
  58. data: {
  59. username: 'admin',
  60. password: 'admin',
  61. route: [
  62. {
  63. no:'1',
  64. roadName: '',
  65. dateTime: '',
  66. ignition: '',
  67. deviceName: '',
  68. rpm: '',
  69. speed: '',
  70. heading: '',
  71. longitude: '',
  72. latitude: '',
  73. geofences: '',
  74. mileage: ''
  75. }
  76. ]
  77. },
  78. methods: {
  79.  
  80. getToken: function() {
  81. this.$http.post('localhost/api_users/login', { username: this.username, password: this.password} ).then((response) => {
  82. console.log(response.data.token);
  83. }, (response) => {
  84. console.log('Login Gagal');
  85. });
  86. }
  87. }
  88. });
  89.  
  90. </script>
  91.  
  92. </body>
  93. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement