[Help needed] Using promise in vue-resource
See original GitHub issueHi, Thanks for your help and reading this:
I am trying to make two api calls and then combine the results together.
Here is my current approach using Promise.all, In the feature, it says ’ Support Promise API’ , what does it mean? Could you kindly show an example how to do it with Vue-resource. Thanks vey much!
var promise1 = new Promise((resolve, reject) => {
Vue.http.get('url1').then((response) => {
resolve(response.json())
}, (response) => {
reject(response.status)
})
})
var promise2 = new Promise((resolve, reject) => {
Vue.http.get('url2').then((response) => {
resolve(response.json())
}, (response) => {
reject(response.status)
})
})
Promise.all([promise1, promise2]).then(([v1,v2]) => {
// Process of merging results v1 and v2 together here
})
Issue Analytics
- State:
- Created 7 years ago
- Comments:6
Top Results From Across the Web
Vue Resource and promises - Laracasts
Hi,. I can use some help getting my promises to work with Vue Router and Vue Resource. ... My first example can work...
Read more >Intercept Promise error with vue-resource - Stack Overflow
I'm using vue-resource and my interceptor is the following: Vue.http.interceptors.push(function(request, next) { ...
Read more >VueJS - Why you should be using promises - YouTube
If you want the source code let me know in the comments section and I will upload it as soon as possible. Please...
Read more >Reacting to Promises from event listeners in Vue.js - Medium
First things first, returning the promise. Its a good practice to always return promises from functions, that way you can await them, if...
Read more >Vue-resource json() is promise? - Get Help
How can I retrieve my data from my response object in vue-resource 1.0.x? this.$http.get('/api').then(function(response){ response.json() ?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mikeyao
For anyone looking for an answer to the above question: yes,
vue-resource
takes care of Promise.all (and other Promise methods as well).