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
13
votes
2 answers

CORS error even after setting Access-Control-Allow-Origin or other Access-Control-Allow-* headers on client side

I have a Vue application generated with webpack-simple option. I am trying to make a GET request to https://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en but I get the error: XMLHttpRequest cannot load …
wrahim
  • 1,158
  • 4
  • 16
  • 33
13
votes
2 answers

vue-resource interceptor for auth headers

I am trying to set up a Vuejs fronted application (vue-cli webpack template) to sit on top of my Laravel API. I am able to get a successful response from the API with vue-resource by providing the correct auth token, for example: methods: { …
tam5
  • 3,197
  • 5
  • 24
  • 45
12
votes
5 answers

How to use vue-resource ($http) and vue-router ($route) in a vuex store?

Before I was getting movie detail from the component's script. The function first check whether the movie ID of the store is same as of the route's param movie ID. If its same then don't get the movie from the server API, or else get the movie from…
Benjamin Smith Max
  • 2,668
  • 8
  • 33
  • 56
11
votes
3 answers

How to add extra header to post request with vue-resource?

I have a number of post requests in my app. Some of them have to have and extrace header with token I'm not sure how to append it So far my code is like this. I'm checking if there is a token and when append it to headers and after that I make post…
Person
  • 2,190
  • 7
  • 30
  • 58
11
votes
1 answer

Provisional headers are shown and pending requests

I have a problem with vue-resource causing a Provisional headers are shown on Chrome, using jQuery on the other hand work without any problem The problem only happens with Chrome + vue-resource Reproduction Link Chrome 57.0.2987 Windows 7 I don't…
Tarik
  • 2,151
  • 4
  • 19
  • 26
11
votes
1 answer

Basic vue.js 2 and vue-resource http get with variable assignment

I'm really struggling to get the most basic REST functionality to work in vue.js 2. I'd like to get data from some endpoint and assign the returned value to a variable of my Vue instance. Here's how far I got. var link =…
user7026341
10
votes
3 answers

How to capture any keypress event in Vuejs without using input element

I am making kind of game in which I want user to enter a particular word and then I want to check if the particular word is pressed. If the word is pressed I will fetch the next word. Currently I am using a form and have used v-model shown below : …
Sagar Karira
  • 669
  • 2
  • 7
  • 20
10
votes
1 answer

Attaching data (body) to $http.delete event in VueJS

I have the following method in my Vue.JS component: removeItems (itemsArray) { this.$http.delete(this.apiUrl, {items : itemsArray}) .then((response) => { this.msg = response.msg; }); } In vue-resource 0.8.0 everything worked…
ierdna
  • 5,753
  • 7
  • 50
  • 84
9
votes
1 answer

How to redirect user inside vue-resource http interceptor?

I want to redirect the user when I have an 401, but I can't access the router from this context: Vue.http.interceptors.push(function(request, next) { // continue to next interceptor next(function(response) { if(response.status ==…
thur
  • 964
  • 1
  • 15
  • 27
9
votes
2 answers

Vuejs and Laravel Post Request CORS

I dont get it. I am struggling with this since hours I am using Vue.js with Laravel and try to make a POST Request to an external API. But i am always getting a CORS error on my Vue POST Request methods: { chargeCustomer(){ …
bobbybackblech
  • 1,868
  • 5
  • 20
  • 22
9
votes
3 answers

Vue.js $remove not removing element after deleted from database

I am using Laravel and trying to learn Vue.js. I have a delete request that is working properly and deleting the object from the database. The problem is that it is not being removed from the DOM after the successful deletion. I am using the $remove…
dericcain
  • 2,182
  • 7
  • 30
  • 52
8
votes
1 answer

vue-resource: catch "Uncaught (in promise)" when intercepting an ajax error

I'm using vue-resource to fetch data from the server. A user needs to have a JWT token to get the correct data. If the token is invalid or expired, a 401 status is returned. If the user tries to access a forbidden page, a 403 is returned. I would…
ssc-hrep3
  • 15,024
  • 7
  • 48
  • 87
8
votes
2 answers

Switching from vue-resource to axios

With vue-resource, we could set the root url in main.js like so: Vue.http.options.root = 'http://localhost:3000/api' I tried replacing that with: axios.defaults.baseURL = 'http://localhost:3000/api'; Vue.prototype.$http = axios However, now my…
softcode
  • 4,358
  • 12
  • 41
  • 68
8
votes
2 answers

How to access an API with Vue.js?

I'm new to JavaScript and Vue.js, and I'm having trouble accessing an api using Vue.js. The API I'm trying to access has JSON that looks like this: { "coord": { "lon": -88.99, "lat": 40.51 }, "weather": [ { …
thefreebird777
  • 99
  • 1
  • 1
  • 8
7
votes
3 answers

VueJS Read Dom Attributes

I want to get the href attribute to the button click event. Get Data Main.JS Files new Vue({ el: 'body', methods: { func: function…
Cesur APAYDIN
  • 806
  • 3
  • 11
  • 24
1
2
3
26 27