I have a problem that I know is not very challenging. But for some reason, I am having difficulty coming up with a good solution. I need to fetch data from a URL. The URL itself, however, is fetched from another end-point. So, first I fetch an object containing the URL from the server. Upon getting the URL, I access the fetched URL which finally gives me the data I need. The data contains further URLs which I eventually have to fetch. How do I fetch all these data from model hook of ember route?
model(params) {
let futureData = new Ember.RSVP.Promise((resolve,reject) => {
api.ajaxGet(
`${api.buildV3EnterpriseUrl('reports')}` + '/' + params.report_id
).then(function (successVal) {
resolve(successVal);
}, function (error) {
reject(error);
});
});
futureData.then((success) => {
return
api.xmlRequest('GET',success.aggregationUrls.elements[0].url);
})
return Ember.RSVP.hash({
reportData: futureData
});
}