vue-resource is an HTTP client plugin for Vue.js, designed for making web requests and handling responses using XMLHttpRequest or JSONP. It supports the Promise API, URI Templates, and interceptors for both requests and responses. The package, currently at version 1.5.3 (last updated in 2021), was primarily built for Vue 1.x and Vue 2.x applications. It boasts compatibility with modern browsers (Firefox, Chrome, Safari, Opera, IE9+) and a compact size (14KB, 5.3KB gzipped). While it was once considered a de-facto 'official' HTTP client, its maintenance has largely ceased, especially with the advent of Vue 3, which encourages the use of alternatives like Axios or the native Fetch API. Its release cadence was irregular towards the end of its active lifecycle, with its last update occurring several years ago.
npm install vue-resourceVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install `vue-resource` as a Vue plugin, perform basic GET and POST HTTP requests within a Vue component's lifecycle hook, and handle both successful responses and errors by updating component data.
Replace the `progress` option with `uploadProgress` and `downloadProgress` methods in your request configuration. These methods receive a standard `ProgressEvent`.
Update interceptor functions to `return response` or `return Promise.resolve(response)` instead of invoking `next(response)` or `next(request)`. Similarly, error paths should `return Promise.reject(error)`.
For Vue 3 applications, migrate to modern HTTP clients like Axios or the native Fetch API, which are actively maintained and designed for the Vue 3 ecosystem. If migrating a Vue 2 app, consider the Vue 3 Migration Build (`@vue/compat`) to ease the transition while replacing deprecated functionalities.
Developers should avoid starting new projects with `vue-resource`. For existing projects, consider migrating to actively maintained alternatives like Axios or the native Fetch API to ensure ongoing compatibility, security updates, and access to new features.
Ensure `Vue.use(VueResource)` is called before creating your Vue instance. For TypeScript, add a declaration file (e.g., `vue-shims.d.ts`) to augment the `Vue` type with `$http`: `declare module 'vue/types/vue' { interface Vue { $http: typeof VueResource.http; } }`.If using CommonJS, ensure `Vue` is imported and defined before `Vue.use(VueResource)`. If in a browser, confirm Vue is loaded via a `<script>` tag before `vue-resource`, or use an ES module setup with a bundler.
Verify that the code accessing `this.$http` is within a Vue component method, lifecycle hook, or a computed property. Confirm `Vue.use(VueResource)` is executed at the application's entry point before any components are initialized.
No dependency data recorded yet.