Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. <template>
  3.   <div class="counter">
  4.     <h3>
  5.       <span>{{info}}</span>
  6.       <br />
  7.     </h3>
  8.     <p>参加中!</p>
  9.   </div>
  10. </template>
  11.  
  12. <script>
  13. import Vue from 'vue';
  14. import axios from "axios";
  15. //import axios from '~plugins/axios';
  16. import API from '../api';
  17.  
  18. Vue.prototype.$http = axios;
  19.  
  20. export default {
  21.   async asyncData(req) {
  22.     let { data } = await axios.get('https://api.mcsrvstat.us/2/visit.morino.party')
  23.     this.info = response.players.online;
  24.     return {
  25.       info: null,
  26.       loading: true,
  27.       errored: false
  28.     };
  29.   },
  30.   methods: {
  31.     serverInfo() {
  32.     //created() {
  33.       axios.get('https://api.mcsrvstat.us/2/visit.morino.party')
  34.         .then((res) => {
  35.           this.info = response.players.online;
  36.           console.log(response);
  37.         })
  38.         .catch(function(error) {
  39.           console.log(error);
  40.         })
  41.         .finally(() => (this.loading = false));
  42.        
  43.     },
  44.   header: {
  45.     "Content-Type": "application/json",
  46.     "X-Requested-With": "XMLHttpRequest",
  47.     responseType: "json"
  48.   },
  49.   xsrfCookieName: "csrftoken",
  50.   xsrfHeaderName: "X-CSRFToken",
  51.   withCredentials: true
  52.   }
  53. };
  54. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement