sergiodlopes / jquery-flexdatalist

Flexible input autocomplete/datalist plugin for jQuery
http://projects.sergiodinislopes.pt/flexdatalist/
MIT License
365 stars 84 forks source link

Sending request header #204

Closed ozgurg closed 5 years ago

ozgurg commented 5 years ago

Hi. How can I send request header for authentication?

davidkryzaniak commented 1 year ago

You can use the data-request-headers option. Here's an example using WordPress and the WP-Nonce header:

$nonce = wp_create_nonce( 'wp_rest' );
echo <<<HTML
<input type='text'
       class='flexdatalist'
       data-url="https://example.com/wp-json/my-example-plugin/v1/some-custom-endpoint/"
       data-request-headers='{"X-WP-Nonce":"$nonce"}'
       >
HTML;