Fuzzwork Market Data: {Headers} problem

I am trying to get pricedata with the API from Fuzzwork Market Data.
I have setup this simple ajax request in javascript but I keep getting this error:

Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8000’ is therefore not allowed access.

But I did set the header as you can see below.
Am I missing something?
please halp :slight_smile:

function getMarketPrices() {
let marketUrl = 'https://market.fuzzwork.co.uk/aggregates/?station=60003760&types=34,35,36,37,38,39,40';

$.ajax({
    url: marketUrl,
    headers: { 
        'Access-Control-Allow-Origin': 'http://localhost:8000'
    },
    success: function (response) {
        console.log(response);
    },
    error: function (response) {
        console.log(response)
    }
});

}

link to Fuzzwork API: https://market.fuzzwork.co.uk/api/

Got the simple version working now.
Had to remove the headers object, and set (crossDomain: true).

function getMarketPrices() {
let marketUrl = 'https://market.fuzzwork.co.uk/aggregates/station=60003760&types=34,35,36,37,38,39,40';

$.ajax({
    url: marketUrl,
    crossDomain: true,
    success: function (response) {
        console.log(response);
    },
    error: function (response) {
        console.log(response)
    }
});

But in my app I first do some ajax requests to ESI. and when they finish, I do this
one request to fuzzwork market api.

And I get the same error again :tired_face:

So it works perfectly on its own, but when I use this in my program that makes some calls to ESI first it wont work…

please HALP!

After lots of googling I finally found a solution!

if($.ajaxSettings && $.ajaxSettings.headers) {
    delete $.ajaxSettings.headers.Authorization;
}

Those 2 lines of code will remove the previous set header that ajax used for the ESI calls.

after that I can just use:

$.get(marketUrl, function(marketdata) {
    console.log('Get marketdata success');
});

:tada::tada::tada::tada::tada::tada::tada::tada::tada::tada:

Glad to see you got it working :smiley:

(Good thing I’m not the kind of evil bastard who would log auth headers to steal them :wink: )

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.