Skip to content

Inject dynamic additional parameters to url #43

Answered by niketpathak
SneakyGerald asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @SneakyGerald , Thank you for your comment.

To pass more data via GET parameters, you can use a callback that returns a string. For example

typeahead({
  input: document.querySelector('.search'),
  source: {
    identifier: 'name',
    remote: {
      url: () => { 
          const token = window.token || ''; // get the necessary token
          return `https://restcountries.com/v2/name/%QUERY/?token=${token}` 
      },
      wildcard: '%QUERY',
    },
  },
  highlight: true,
  limit: 10
})

You can also pass more data using the requestOptions parameter of the remote/prefetch sources. (https://typeahead.digitalfortress.tech/#config?id=source)

An example using a remote source is shown …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@SneakyGerald
Comment options

@niketpathak
Comment options

@SneakyGerald
Comment options

Answer selected by SneakyGerald
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants