Get started with vue-resource CDN

MIT licensed

Vue-resource: Simplifies API requests, fetches data in Vue.js apps.

Tags:
  • vue
  • vuejs
  • resource
  • mvvm

Stable version

Copied!

How to start using vue-resource CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with vue-resource CDN - cdnhub.io</title>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.min.js"></script>
  <script src="https://cdn.cdnhub.io/vue-resource/1.5.3/vue-resource.min.js"></script>
</head>
<body>
  <div id="app">
    <button @click="fetchData">Fetch Data</button>
    <p v-if="data">{{ data }}</p>
  </div>
  <script>
    new Vue({
      el: '#app',
      data: {
        data: null
      },
      methods: {
        fetchData() {
          Vue.http.get('https://jsonplaceholder.typicode.com/todos/1')
            .then(response => {
              this.data = response.body.title;
            })
            .catch(error => {
              console.log(error);
            });
        }
      }
    });
  </script>
</body>
</html>
Copied!
Copied!

All versions