Javascript - Add authorization header with the shorthand jQuery

I'm using the shorthand $.get instead of $.ajax{type : "GET ... }

Is it possible to define the Authorization header with this shorthand?

Upvotes: 1

Views: 560

Answers (1)

Arup Rakshit
Arup Rakshit

Reputation: 118299

Yes add the headers: {} key. Check setting from Jquery official doc.

$.get({headers: {}})

The offcial doc says:

A set of key/value pairs that configure the Ajax request. All properties except for url are optional. A default can be set for any option with $.ajaxSetup(). See jQuery.ajax( settings ) for a complete list of all settings. The type option will automatically be set to GET.

Upvotes: 1

Related Questions