How do I pass the api key in javascript

Imported Google Group message. Original thread at: https://groups.google.com/forum/#!topic/tyk-community-support/knI5x1wgIP0 Import Date: 2016-01-19 21:23:13 +0000.
Sender:Narongrit Tuntivarachai.
Date:Wednesday, 9 September 2015 11:17:08 UTC+1.

Hi Martin,

I’m implementing web page to get my data via your API gateway and successful with Keyless setting.
Now, I’m trying to use Auth Token but I don’t know how do I pass the api key in javascript.

Many Thanks for helping
Narongrit

Imported Google Group message.
Sender:Martin Buhr.
Date:Wednesday, 9 September 2015 11:32:50 UTC+1.

hi Narongrit,

You can do this with jQuery, take a look at the ajax() method: http://api.jquery.com/jquery.ajax/ which allows you to control all elements of a request made to an API, you would need to set the headers or add a query parameter depending on your setup.

You’ll need to set the “header” or query parameter information to an appropriate API token that Tyk can read.

I’d also recommend enabling the CORS features of the gateway to be a bit more secure.

Cheers,
Maritn