How fetchCallback works? #262
Answered
by
mskocik
Divinely5782
asked this question in
Q&A
-
|
Hi! Thanks for this plugin! I am trying to fetch cities from remote api, but this api returns me an array of objects,like: fetchCallback function is: I just want to extract Name and timezone for future usage. |
Beta Was this translation helpful? Give feedback.
Answered by
mskocik
Nov 17, 2024
Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
mskocik
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Hi,
fetchCallbackmust return array of objects where every object must have property representing value (let's call itvalue) and text (this islabel), which is being shown to users.Svelecte automatically tries to pick following properties if they exist in option objects:
valueone of these properties is tried (in this order):['id', 'value', 'ID']labelthis list is used:['name', 'title', 'label']So when we take your example option object, you don't need to do anything, because Svelecte should automatically use
idproperty forvalueandnameforlabel. If you would like to specify some other properties, you can usevalueFieldandlabelFieldproperties to define which propert…