How to correctly pass an authorization token in the header using Javascript and the Papa Parse library?

Asked

Viewed 16 times

0

I’m using the library Papa Parse in Javascript to download some dataset in CSV format and then read the data. It was working perfectly until they implemented a token authentication in the database. I have this authorization token, I did several tests trying to pass as header parameter, inspiring me in the guidelines contained in the documentation of library, but still can’t properly authenticate and receive the file as I received before:

function loadInfoEstados() {
    Papa.parse("https://brasil.io/dataset/covid19/caso_full/?place_type=city&is_last=True&is_repeated=False&format=csv", {
        header: true,
        download: true,
        dynamicTyping: true,
        downloadRequestHeaders: {
            'Authorization': 'token 0123345678901234567890',
        },
        complete: function(results) {
            var estrutura = results.data;
            estadosJSON(estrutura);
            id = "estado";
        }
    });
}

Someone went through a similar situation and managed to solve?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.