0

TypeError: undefined is not an object (evaluating 'getImages.data[0].s_path')

const getImages = responseApi(imgApi.getItemImg); API DATA getImages data 👇 Array [ Object { "dt_pub_date": "2019-07-30 09:41:58", "fk_i_item_id": "1090", "pk_i_id": "1092", "s_content_type": "image/jpeg", "s_extension": "jpg", "s_name": "inbLX2Cd", "s_path": "oc-content/uploads/10/", }, Object { "dt_pub_date": "2019-07-30 09:41:58", "fk_i_item_id": "1086", "pk_i_id": "1088", "s_content_type": "image/jpeg", "s_extension": "jpg", "s_name": "nlJf1TUl", "s_path": "oc-content/uploads/10/", }, ] ‘{getImages.data[0].s_path}${getImages.data[0].pk_i_id}.${getImages.data[0].s_extension}’ How to solve? TypeError: undefined is not an object (evaluating 'getImages.data[0].s_path')

26th Oct 2020, 12:34 PM
Arjit Sing
Arjit Sing - avatar
5 RĂ©ponses
+ 4
Whst is `getImages` here? It is probably undefined.. From where it is coming? Any code? Edit: Arjit Sing const getImages = responseApi(imgApi.getItemImg); // this line is perhaps the issue Try the above line inside a callback maybe, if it isn't inside callback.. (I need some more code here) I think the response isn't prepared at the time of assignment, so `getImages` maybe undefined!
26th Oct 2020, 12:39 PM
777
777 - avatar
+ 1
yes array of data from getImages Edit: same undefined i think problem index number
26th Oct 2020, 1:10 PM
Arjit Sing
Arjit Sing - avatar
+ 1
Firstly, it isn't yet cleared what the problem is in your code, so giving arbitrary help would make it worse, okay? Secondly, you aren't suppose to create a callback mostly (for APIs). However, if you're interested, search for "callbacks in javascript", there you'll get better expln & resources than me. And, what is index number? I don't think `data[0]` is a problem..
26th Oct 2020, 1:47 PM
777
777 - avatar
0
i’m new how can i create a callback
26th Oct 2020, 1:41 PM
Arjit Sing
Arjit Sing - avatar
0
okay thanks
26th Oct 2020, 1:51 PM
Arjit Sing
Arjit Sing - avatar