Questions tagged [vue-resource]

An HTTP client plugin for Vue.js to manage web requests and responses using XMLHttpRequests or JSONP

vue-resource

vue-resource is an HTTP client plugin for Vue.js to manage web requests and responses using XMLHttpRequests or JSONP.

Features of the plugin (see README):

  • Supports the Promise API and URI Templates
  • Supports interceptors for request and response
  • Supports latest Firefox, Chrome, Safari, Opera and IE9+
  • Supports Vue 1.0 & Vue 2.0
  • Compact size 14KB (5.3KB gzipped)

vue-resource is no longer part of the official recommendation list from Vue, Though it still functions as intended and is usable.

"Potential reasons to migrate away include maintenance, universal/isomorphic support and more advanced features. - Vue JS Core Team

Resources

Related Tags

403 questions
697
votes
16 answers

Vue.js - How to properly watch for nested data

I'm trying to understand how to properly watch for some prop variation. I have a parent component (.vue files) that receive data from an ajax call, put the data inside an object and use it to render some child component through a v-for directive,…
Plastic
  • 9,874
  • 6
  • 32
  • 53
73
votes
26 answers

VueJs dev tools panel not showing

I started using vue dev-tools in my application but it is not visible when in developer mode in Chrome. I tried various solutions found on the dev-tools github page and in other places on the web, but no luck. Below are the things i have done/tried…
Malik
  • 3,520
  • 7
  • 29
  • 42
54
votes
6 answers

Is there any way to 'watch' for localstorage in Vuejs?

I'm attempting to watch for localstorage: Template:

token - {{token}}

Script: computed: { token() { return localStorage.getItem('token'); } } But it doesn't change, when token changes. Only after refreshing the page. Is there a…
artem0071
  • 2,369
  • 3
  • 14
  • 25
41
votes
3 answers

Include global functions in Vue.js

In my Vue.js application I want to have some global functions. For example a callApi() function which I can call every time I need access to my data. What is the best way to include these functions so I can access it in all my components? Should I…
Jordy
  • 4,719
  • 11
  • 47
  • 81
38
votes
1 answer

Push to vuex store array not working in VueJS

I'm using Vuex to show a list of users from 'store.js'. That js file has array like this. var store = new Vuex.Store({ state: { customers: [ { id: '1', name: 'user 1',}, ] } }) I want to insert a new set of values to the same…
Gijo Varghese
  • 11,264
  • 22
  • 73
  • 122
36
votes
6 answers

CORS issue with Vue.js

I'm using: Vue 2.0.3 vue-router 2.0.1 vuex 0.8.2 vue-resource 0.7.0 And after trying to login to my page when using remote API, not the locally run one, I get cors error like following vue-resource.common.js?2f13:1074 OPTIONS…
desicne
  • 851
  • 2
  • 9
  • 23
35
votes
4 answers

Which VueJS lifecycle hook must Asynchronous HTTP requests be called in?

I'd like to know how before I render a page, I want to send an async GET request to my server to retrieve data and populate the properties in data. I heard the best way to do this is to call the function that sends this request in one of the three…
Baalateja Kataru
  • 851
  • 2
  • 11
  • 11
27
votes
4 answers

Params field is empty in $router.push

Consider this: this.$root.$router.push({ path: '/dashboard', params: { errors: 'error' }, query: { test: 'test' } }) I use this in my component to redirect to another URL, and some error has occured. The problem is that when I want to…
Jozef Cipa
  • 2,133
  • 3
  • 15
  • 29
26
votes
1 answer

Vue Resource root options not used?

I specify a root options in my Vue-Resource in my main.js file, but when I do the request, it does not use the root options. What am I missing ? Here's the code : main.js: Vue.http.options.root = 'http://api.domain.com/v1/' In a component : ready:…
Cyril N.
  • 38,875
  • 36
  • 142
  • 243
17
votes
1 answer

What is the right way to make API calls with Vuex?

I have a Vue Webpack app with Vuex (I am new to both, coming in from the Ember world). I've currently got it setup to use vue-resource with two files like this: /src/store/api.js import Vue from 'vue'; import { store } from './store'; export…
JackH
  • 4,613
  • 4
  • 36
  • 61
17
votes
1 answer

How to make an async call in a beforeCreate hook of a Vue instance?

I am building a Vuejs app with authentication. When the page is loaded and I initialise the app Vuejs instance, I am using beforeCreate hook to set up the user object. I load a JWT from localStorage and send it to the backend for verification. The…
Gábor Pintér
  • 981
  • 2
  • 9
  • 24
15
votes
1 answer

Structuring a Vue + Vuex project

I am kind of confused here on where to place my global functions. In a lot of examples a main.js file points to an app component and this is placed somewhere within the html. This workflow would be fine for me If I were to simply contain all my…
Stephan-v
  • 19,255
  • 31
  • 115
  • 201
15
votes
3 answers

Vuejs synchronously request before render data

I have single page application that requires authentication. When user was authenticated then visit some pages or hit reload button in browser it will request an api that provide their auth data. then I have an error like this: [Vue warn]: Error…
antoniputra
  • 4,251
  • 6
  • 26
  • 31
15
votes
1 answer

Why am I getting a 422 error code?

I am making a POST request, but unable to get anything besides a 422 response. Vue.js client code: new Vue({ el: '#app', data: { form: { companyName: '', street: '', city: '', state: '', zip: '', …
Donnie
  • 6,229
  • 8
  • 35
  • 53
13
votes
2 answers

mounted method is fired before data loaded - VueJS

I'm using Vue Resource to retrieve an images collection from a REST API. The request is sent in the created hook of my Vue component. The problem is, I'm trying to access the retrieved data in the mounted hook, but the data isn't loaded. I get…
BrownBe
  • 977
  • 3
  • 11
  • 23
1
2 3
26 27