Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <template>
  2. <div>
  3. <table>
  4. <tr>
  5. <th>Waluta</th>
  6. <th>Kod ISO</th>
  7. <th>Kurs</th>
  8. </tr>
  9. <template v-for='item in table'>
  10. <tr :key='item.code'>
  11. <td>{{item.currency}}</td>
  12. <td>{{item.code}}</td>
  13. <td>{{item.mid}}</td>
  14. </tr>
  15. </template>
  16. </table>
  17. </div>
  18. </template>
  19.  
  20. <script>
  21. import axios from 'axios';
  22. export default {
  23. name: 'app',
  24. data: () => ({
  25. table: [
  26. {currency: 'polski zloty', code: 'PLN', mid: 1}
  27. ],
  28. }),
  29. mounted() {
  30. this.api().get('exchangerates/tables/a/')
  31. .then(response => response.data[0].rates.forEach(i => this.add(i)));
  32. },
  33. methods: {
  34. add(el) {
  35. this.table.push(el)
  36. },
  37. api() {
  38. return axios.create({
  39. baseURL: 'https://api.nbp.pl/api/',
  40. timeout: 1000,
  41. headers: {Accept: 'application/json'}
  42. })
  43. }
  44. }
  45. }
  46. </script>
  47.  
  48. <style>
  49.  
  50. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement