Make remote URL dynamic to allow multiple params for API call #36
Replies: 4 comments 2 replies
-
Hello @niels-heinemann, Thank you for your comment. Actually there exists a mechanism to pass more data using the An example using a remote source is shown below for further clarity typeahead({
input: document.querySelector('.search'),
source: {
identifier: 'name',
remote: {
url: 'https://restcountries.com/v2/name/%QUERY',
wildcard: '%QUERY',
requestOptions: {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: 'Clark Kent' }),
},
},
},
highlight: true,
limit: 10
}) As per the above example, we pass additional data as a key-value pair ( Hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Yeah, thx, I know. This is vanilla fetch options. But I'm afraud I have to use GET parameters. Please do not invest too much time. As I needed this feature I switched to another library today. |
Beta Was this translation helpful? Give feedback.
-
For future readers who need this feature, it has been implemented in v4.13.0. It allows you to use a callback as a URL in remote/prefetch sources. For usage details, refer documentation. |
Beta Was this translation helpful? Give feedback.
-
Jesses, man! That's quite fast. Thx a load. |
Beta Was this translation helpful? Give feedback.
-
What a supercool library, thanks a load.
I think it would be beneficious to allow using a function/callback for url property of remote and prefetch datasources. I have to pass dynamically changnd filter values to the reote api.
If you do not think this would be a valuable new feature, can you provide a precallremote callback?
Beta Was this translation helpful? Give feedback.
All reactions