I think my question is easy but I dont understand why my solution doesnt work :(
I'm trying to add to a new object some long properties using foreach loop but I'm getting the whole time error.
Could someone please help me?
let i = 0;
const obj = {};
for (const item of read) {
console.log(item.name);
console.log(item.imageURL);
obj['hits']['hits'] ='whyDosntWork';
console.log(item.name);
if (item.imageURL) {
obj['hits']['hits'][i]['_source.ActiveChannelReleases'][0]['ImageExports'][0]['Resolutions'][0]['Url'] =getServerURL()+item.imageURL;
} else {
obj['hits']['hits'][i]['_source.ActiveChannelReleases'][0]['ImageExports'][0]['Resolutions'][0]['Url'] ='https://cdn3.iconfinder.com/data/icons/kitchen-glyph-black/2048/4834_-_Cookbook-512.png';
}
console.log(item.imageURL);
i++;
}
I have an response and I want to mock it with my data
I wish to have for example an object that I can fill with data:
class ResponseController {
constructor() {
this.response = {
'hits': {
'hits': [{'_source.ActiveChannelReleases': [{'ImageExports': ['Resolutions']}],
}],
},
};
}
}
module.exports = ResponseController;
Will it work if I write
obj = new ResponseController();
and then I can easily add variables from the looo?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…