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
}
?
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
Most helpful comment
You should use
Promise.allfor this: