Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setRequestHeader #25

Open
samcfc opened this issue Aug 27, 2014 · 6 comments
Open

setRequestHeader #25

samcfc opened this issue Aug 27, 2014 · 6 comments

Comments

@samcfc
Copy link

samcfc commented Aug 27, 2014

Hi thanks for your share,
I think it will be nice to be able to .setRequestHeader from options{requestHeaders:{ key1 : value1, key2 : value2 }...}

I will test it and maybe do my first PR :).

@9SL9
Copy link

9SL9 commented Jul 27, 2015

I agree, really need this functionality to authenticate against web services that require an API key etc. Any progress on this functionality?

@calvinmetcalf calvinmetcalf mentioned this issue Jul 27, 2015
@calvinmetcalf
Copy link
Owner

see #33, note this is only necessary across domains, as if you are on the same domain those headers automatically get set. Also note that it is only for ajax requests that it gets set as you can't set headers for jsonp requests

@wallmarc
Copy link

Any possibility for more progress on #33?

I need this to be able to content-negotiate on an API producing json or geojson by specifying 'accept' with value either 'application/json' or 'application/geo+json'

@calvinmetcalf
Copy link
Owner

ac197b0

@askpatrickw
Copy link

PR #50 does fix this.

@dave-driesmans
Copy link

dave-driesmans commented Feb 4, 2021

This is not entirely clear to me, the docu says:

If you want to set headers to the XMLHttpRequest set the 'headers' option equal to an object.

I thought this should work:

var geojsonLayer = L.geoJson.ajax("route/to/esri.json",{
    	dataType: 'json',
        headers: { 'X-Api-Key': 'jPmTlUOJHtr0JYR8yrsy....' },
});

but probably I'm missing something

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants