Base62 with Vue and axios

Encodes and decodes using external API call with Vue.js and axios()

by pleasureswx123

HTML

<script src="https://unpkg.com/[email protected]/dist/axios.min.js"></script>
<div id="app">
  <p>{{ encoded }}</p>
  <p>{{ a21 }}</p>
  <p>{{ error }}</p>
</div>

JavaScript

/* http://base62.net/ */

var app = new Vue({
  el: "#app",
  data: {
    encoded: "Encoding...",
    a21: '....',
    error: null
  },
  created: function () {
    var self = this;
    /* axios.post('http://localhost/M-Experience/resources/GETrends.php',
              {
        firstName: this.name
              },
              {
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
              }); */
    /*   {
                        headers: {
                          'Content-Type': 'application/json',
                          Authorization: 'Bearer123',
                          withCredentials: true
                          withCredentials
                        }
                      } */
    let data = JSON.stringify({
      password: '[email protected]',
      username: '123456789'
    });

    axios({
      method: 'post',
      url: 'http://sso.vipkid.com:8080/api/sso/logout',
      /* data: {
        firstName: 'Fred'
      }, */
      //headers: {'content-type': 'application/json'},
      //responseType: 'json',
      withCredentials: true
    }).then(function (response) {
      console.log('1', response)
      debugger;
      self.encoded = response.data
    }).catch(function (error) {
      self.error = "Could not reach the API: " + error
    });

    false && axios.post("http://sso.vipkid.com:8080/api/sso/logout",{
      headers: {
        withCredentials: true
      }
    }).then(function (response) {
      console.log('1', response)
      debugger;
      self.encoded = response.data
    }).catch(function (error) {
      self.error = "Could not reach the API: " + error
    });
  }
});