Vue-resource: Does there a request method like promise all?

Created on 5 Jan 2016  Â·  8Comments  Â·  Source: pagekit/vue-resource

Does there support a get method like:

this.$http.all('request_url_1', 'request_url_2' [,]).then(data){
           //data[0]  is res_of_request_1
           //data[1]  is res_of_request_2
}  

?

Most helpful comment

You should use Promise.all for this:

Promise.all([
    this.$http.get('request_url_1'),
    this.$http.get('request_url_1')
]).then(function(data) {
    // data[0]  is res_of_request_1
    // data[1]  is res_of_request_2
});

All 8 comments

You should use Promise.all for this:

Promise.all([
    this.$http.get('request_url_1'),
    this.$http.get('request_url_1')
]).then(function(data) {
    // data[0]  is res_of_request_1
    // data[1]  is res_of_request_2
});

You can use

this.$promise.all([
    this.$http.get('url1'),
    this.$http.get('url2')
]).then(function(responseArr){

});

https://github.com/pagekit/vue-resource/blob/develop/src/promise.js#L22

@dionisnote
In my code, this.$promise.all is not working.Got an error: this.$promise.all is not a function.this not bind to a wrong object.I don't know why.

@alonprince It works only if you use vue-resource
But in last time everybody just use axios

@dionisnote
Yes, I am using vue-resource^2.2.6.But also not working.

@alonprince
https://github.com/pagekit/vue-resource/blob/develop/package.json#L3
Hmm, current stable version is 1.3.1

@dionisnote
I'm so sorry.I just look for the wrong line which records the version info of Vue.
The vue-resource I used is 1.3.1.😂

@alonprince Thats true, it doesn't work now... Anyway you can use promise constructor function, like this
its same of this
https://github.com/pagekit/vue-resource/issues/194#issuecomment-168889377
be cause
https://github.com/pagekit/vue-resource/blob/develop/src/promise.js#L8

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jigsaw5279 picture Jigsaw5279  Â·  5Comments

ionutvelicu picture ionutvelicu  Â·  5Comments

EmilMoe picture EmilMoe  Â·  5Comments

yozman picture yozman  Â·  6Comments

Dreampie picture Dreampie  Â·  3Comments