Can not get feature with attachments

315
2
06-13-2021 08:36 PM
SonMinh
New Contributor

I want to get feature with attachments, i think fetchData is function asynchronous, so it's always print "fetch data not done" first. So how can i get feature with it attachments? Thanks in advance

SonMinh_0-1623641567220.png

 

0 Kudos
2 Replies
Nicholas-Furness
Esri Regular Contributor

Hi,

You are correct. The fetchData method is async, and so you will see the "fetch data not done" message before the fetchData even makes the request. You need to hold on to each "att", which can probably be done by holding on to each "attachments" array in the same way as you are holding on to the "features" array.

Otherwise, each attachments array returned from "fetchAttachments" will go out of scope at the end of the completion block and be deallocated, and so all the "att" objects will be released before their fetchData calls can complete, and their callbacks will not be entered.

2021-06-14_11-40-47.png

Hope that helps!

Nick

0 Kudos
SonMinh
New Contributor

so if i want get each feature with it's attachments, which the best way i can do?  Can you give me code example? Thanks in advance

0 Kudos