Reputation: 1313
I get longDesc
from a second AJAX call and I'd like to merge it with the first call.
My code:
transform: {
fn(data) {
const longDesc = [];
Ext.Ajax.request({
url: `url`,
method: 'GET',
scope: this,
success(response) {
const dataSet = Ext.decode(response.responseText);
Ext.each(dataSet.data, value => {
longDesc.push(value.longDesc);
});
},
failure() {},
});
data.data.longDesc = longDesc;
return data;
},
I get this log:
but I'd like to move longDesc
inside each data object
Upvotes: 0
Views: 32
Reputation: 96
You need to set the longDesc array in each element in data and not attach it directly to data.I think this is what you are trying to achieve-
transform: {
fn(data) {
const longDesc = [];
Ext.Ajax.request({
url: `url`,
method: 'GET',
scope: this,
success(response) {
const dataSet = Ext.decode(response.responseText);
Ext.each(dataSet.data, value => {
longDesc.push(value.longDesc);
});
},
failure() {},
});
data.data.forEach(function(entry) {
entrylongDesc = longDesc;
});
return data;
},
Upvotes: 1